我不想失去的UITextField
焦点的UITextField的焦点不解雇键盘如何失去而不关闭键盘
我有一个UITextField
和一些对象可以长按显示复制菜单在使用。我使用UIMenuController
来显示菜单,然后它必须成为firstResponder => UITextField
将丢失编辑和解雇键盘。
所以,我想让键盘保持在屏幕上,但不专注于UITextField
。这就像Viber,当用户长按邮件复制,但Viber不会解雇键盘。
我不想失去的UITextField
焦点的UITextField的焦点不解雇键盘如何失去而不关闭键盘
我有一个UITextField
和一些对象可以长按显示复制菜单在使用。我使用UIMenuController
来显示菜单,然后它必须成为firstResponder => UITextField
将丢失编辑和解雇键盘。
所以,我想让键盘保持在屏幕上,但不专注于UITextField
。这就像Viber,当用户长按邮件复制,但Viber不会解雇键盘。
只需将下一个UITextField
设置为第一响应者。
键盘不会消失,下一个文本字段将收到它的“击键”。
与UIkeyboard
-(void)viewWillAppear:(BOOL)animated{
[txfield becomeFirstResponder];
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
- (void)keyboardWillShow:(NSNotification *)notification {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView commitAnimations];
NSLog(@"Keyboard");
}
- (void)keyboardWillHide:(NSNotification *)notification {
NSLog(@"NoKeyboard");
}
希望这有助于试试这个附加功能!