Swa*_*tik 5 iphone uitextfield
当用户点击UITextField时,我想要显示一个自定义键盘.但同时我想在文本字段中显示光标.如果if为canBecomeFirstResponder返回NO,则它不显示默认键盘,但也不显示光标.
有人可以帮帮我吗?
谢谢.
覆盖 UITextFieldDelegate 中的以下两个方法。请注意,此方法对 UITextField 和 UITextView 都有效(在这种情况下,您可以覆盖 UITextViewDelegate 中的相应方法)
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if (!textField.inputView) {
//hides the keyboard, but still shows the cursor to allow user to view entire text, even if it exceeds the bounds of the textfield
textField.inputView = [[UIView alloc] initWithFrame:CGRectZero];
}
return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
return NO;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5703 次 |
| 最近记录: |