[英]Keyboard for textfield appears after second tap (time to time)
I have one view in my app where there is 1 text field. 我的应用程序中只有一个视图,其中有1个文本字段。 And I've noticed that keyboard appears after second tap.
而且我注意到第二次点击后出现了键盘。
But it's interesting that on iPhone it's time to time (some time appears after first tap at once, and some time after second tap only). 但是有趣的是,在iPhone上是不定时的(一次单击后会出现一段时间,而第二次单击后会出现一段时间)。 On iPad looks like it more ofter appears after second tap only.
在iPad上,看起来似乎只有第二次点击才出现。
I use UITextFieldDelegate
我使用
UITextFieldDelegate
in viewDidLoad
I assign the delegate _locationTextField.delegate = self;
在
viewDidLoad
我分配委托_locationTextField.delegate = self;
and I use delegate methods textFieldDidBeginEditing
, textFieldDidEndEditing
, textFieldShouldReturn
我使用委托方法
textFieldDidBeginEditing
, textFieldDidEndEditing
, textFieldShouldReturn
eg: 例如:
#pragma mark -
#pragma mark UITextFieldDelegate
- (void)textFieldDidBeginEditing:(UITextField *)textField {
_locationNameBeforeManualEdit = _locationTextField.text;
// save the previod city value to compare after did end editing
NSLog(@"textFieldDidBeginEditing");
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
NSLog(@"textFieldDidEndEditing");
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[self continueButtonPressed:nil];
// [textField resignFirstResponder];
return YES;
}
What could be the problem? 可能是什么问题呢?
Found solution here on Stackoverflow - solution related with keyboard preload: 在Stackoverflow上找到了解决方案-与键盘预加载有关的解决方案:
- (void)preloadKeyboard {
UITextField *lagFreeField = [[UITextField alloc] init];
[self.window addSubview:lagFreeField];
[lagFreeField becomeFirstResponder];
[lagFreeField resignFirstResponder];
[lagFreeField removeFromSuperview];
}
This method should be used in application: didFinishLaunchingWithOptions:
method of AppDelegate
. 此方法应该在使用
application: didFinishLaunchingWithOptions:
的方法AppDelegate
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.