How to detect undock, dock or split is pressed on iPad (iOS 5)

那年仲夏 提交于 2020-01-14 14:31:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!