Objective c 将UITextField上的日期选择器带到前端
当一个UIExtField是firstResponder时,我想在屏幕的底部显示一个UIDatePicker,而不使用键盘,不调用UIExtField resignFirstResponder 其目的是像UIExtField的UIKeyboard一样处理,当它成为第一响应者时,几乎所有东西都会弹出。modalViewController似乎是全屏的Objective c 将UITextField上的日期选择器带到前端,objective-c,uiview,uitextfield,uidatepicker,uikeyboard,Objective C,Uiview,Uitextfield,Uidatepicker,Uikeyboard,当一个UIExtField是firstResponder时,我想在屏幕的底部显示一个UIDatePicker,而不使用键盘,不调用UIExtField resignFirstResponder 其目的是像UIExtField的UIKeyboard一样处理,当它成为第一响应者时,几乎所有东西都会弹出。modalViewController似乎是全屏的 - showDatePicker:(id)sender { if([taskName isFirstResponder]) [taskNa
- showDatePicker:(id)sender {
if([taskName isFirstResponder]) [taskName resignFirstResponder];
[self.view.window addSubview: self.pickerView];
// size up the picker view and compute the start/end frame origin
(...)
[UIView commitAnimations];
}
这个例子是一个键盘下降,日期选择器上升的动画,在后面而不是前面
你知道解决办法吗?一段代码是受欢迎的。提前谢谢。这绝对可以做到。。。在.h中设置UIViewController后,只需实现以下方法 长话短说,这会在文本编辑开始之前覆盖键盘加载
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
// Make a new view, or do what you want here
UIDatePicker *pv = [[UIDatePicker alloc] initWithFrame:CGRectMake(0,245,0,0)];
[self.view addSubview:pv];
return NO;
}
这绝对可以做到。。。在.h中设置UIViewController后,只需实现以下方法 长话短说,这会在文本编辑开始之前覆盖键盘加载
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
// Make a new view, or do what you want here
UIDatePicker *pv = [[UIDatePicker alloc] initWithFrame:CGRectMake(0,245,0,0)];
[self.view addSubview:pv];
return NO;
}
这只需将文本字段的输入视图设置为选择器视图即可完成。然后,在编辑时确实开始告诉选择器视图成为第一响应者。像这样
textField.inputView = pickerView
然后在编辑确实开始时使用调用的iAction
-(IBAction) setPickerViewAsFirstResponder:(id)sender
{
[pickerView becomeFirstResponder];
}
这很好用。您需要实现代码,以便将选择器视图当前显示的内容实际设置为文本字段中的字符串。只需将文本字段的输入视图设置为选择器视图即可。然后,在编辑时确实开始告诉选择器视图成为第一响应者。像这样
textField.inputView = pickerView
然后在编辑确实开始时使用调用的iAction
-(IBAction) setPickerViewAsFirstResponder:(id)sender
{
[pickerView becomeFirstResponder];
}
这很好用。您需要实现代码来实际设置选择器视图当前在文本字段中显示的字符串