2013-02-20 59 views
0

我不想失去的UITextField焦點的UITextField的焦點不解僱鍵盤如何失去而不關閉鍵盤

我有一個UITextField和一些對象可以長按顯示覆制菜單在使用。我使用UIMenuController來顯示菜單,然後它必須成爲firstResponder => UITextField將丟失編輯和解僱鍵盤。

所以,我想讓鍵盤保持在屏幕上,但不專注於UITextField。這就像Viber,當用戶長按郵件複製,但Viber不會解僱鍵盤。

回答

0

只需將下一個UITextField設置爲第一響應者。

鍵盤不會消失,下一個文本字段將收到它的「擊鍵」。

0

與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"); 

} 

希望這有助於試試這個附加功能!