我有一个写有日期的 uitextfield.. 我怎样才能在页面底部显示一个 uidatepicker 而不是标准键盘? 提前致谢
最佳答案
确保你的类实现了UITextFieldDelegate
协议(protocol)。然后,覆盖 shouldBeginEditing
委托(delegate)方法以返回 FALSE:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
//check if it is the UITextField you don't want the keyboard for
if (textField != dateTextField)
return TRUE;
//present your UIDatePicker
//see instructions below
//Return false to prevent the keyboard from appearing.
return FALSE;
}
我建议使用另一个包含 UIDatePicker
的 UIViewController
并使用 presentModalViewController
来显示它。这符合用户界面指南。
关于ios UITextField 使用 uidatepicker 进行编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4729723/