问题
I am trying to detect dock key is pressed or not on my iPad. This dock key is a new feature in iOS 5. When this key is pressed the keyboard disappears. I need to detect it. When this key is pressed I need to change the frame of my view, but I couldn't get any event by pressing this key.
I am trying to use the following function:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
NSLog(@"TEXT: %@", text);
return YES;
}
When I pressed 'A' this function is called and print TEXT: A, but when dock key is pressed, this function wasn't called!
Is there a way to detect dock key on iPad? For clarification, the dock key is available on iPad (only in iOS 5) at the bottom right corner of the keyboard.
ANSWER::::
I used the following code in viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil];
and I got the event in method -(void)keyboardWillHide
-(void)keyboardWillHide
{
NSLog(@"Pressed...");
}
thanks borrrden.
回答1:
When the user presses the dock key, you will be notified via the UIKeyboardWillHideNotification from NSNotificationCenter.
来源:https://stackoverflow.com/questions/10009444/how-to-detect-undock-dock-or-split-is-pressed-on-ipad-ios-5