在iPad上按下如何检测取消停靠,停靠或拆分(iOS 5) [英] How to detect undock, dock or split is pressed on iPad (iOS 5)
问题描述
我正在尝试检测我的iPad上是否按下了停靠键。此停靠键是iOS 5中的新功能。按下此键后,键盘将消失。我需要检测它。按下此键时,我需要更改视图的框架,但按下此键无法获得任何事件。
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;
}
当我按下A时,调用此函数并打印TEXT:A,但是当按下停靠键时,没有调用此功能!
When I pressed 'A' this function is called and print TEXT: A, but when dock key is pressed, this function wasn't called!
有没有办法在iPad上检测停靠键?为了便于说明,可以在键盘右下角的iPad(仅限iOS 5)上使用停靠键。
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 ::::
我在viewDidLoad中使用了以下代码:
I used the following code in viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil];
我在方法中得到了事件 - (无效)keyboardWillHide
and I got the event in method -(void)keyboardWillHide
-(void)keyboardWillHide
{
NSLog(@"Pressed...");
}
感谢borrrden。
thanks borrrden.
推荐答案
当用户按下停靠键时,将通过NSNotificationCenter的UIKeyboardWillHideNotification通知您。
When the user presses the dock key, you will be notified via the UIKeyboardWillHideNotification from NSNotificationCenter.
这篇关于在iPad上按下如何检测取消停靠,停靠或拆分(iOS 5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!