ghi*_*boz 6 editing uidatepicker uitextfield uiviewcontroller ios
我有一个uitextfield写的日期..如何在页面底部显示一个uidatepicker而不是标准键盘?提前致谢
确保您的类实现UITextFieldDelegate协议.然后,重写shouldBeginEditing委托方法以返回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;
}
Run Code Online (Sandbox Code Playgroud)
我建议使用另一个UIViewController包含a UIDatePicker并用于presentModalViewController显示它.这符合用户界面指南.
UITextField为此提供了一种机制.您应该能够将另一个视图(如datepicker)设置为inputView.看这篇文章:
| 归档时间: |
|
| 查看次数: |
9300 次 |
| 最近记录: |