如何检查我的 iOS 键盘是否显示字典或单词建议(我不知道正确的术语)。
我在网上搜索过,但没有找到答案。 在那些单词建议/字典后面是我的输入字段,但是当单词建议/字典出现时它被隐藏在它后面。我希望我的输入在出现建议/词典时动态地将其放在单词建议/字典的顶部。为此,只要出现单词建议/字典,我只需要一个通知。有人知道怎么做吗?
最佳答案
我也不知道建议栏术语是什么...
但是你可以使用 NSNotificationCenter 来观察键盘调整大小的通知
尝试一下。
也许有帮助~
- (void)viewDidLoad {
[super viewDidLoad];
//add UIKeyboardWillShowNotification to NSNotificationCenter
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardShow:)
name:UIKeyboardWillShowNotification
object:nil];
}
- (void)keyboardShow:(NSNotification *)notification{
//Should Log when keyboard show or resize
NSLog(@"keyboard notification");
NSDictionary *userInfo = [notification userInfo];
//Get the keyboard
NSValue *keyBoardValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
//Get the keyboard Rect
CGRect keyboardRect = [keyBoardValue CGRectValue];
NSLog(@"%@",[NSValue valueWithCGRect:keyboardRect]);
}
然后当你操作键盘的时候
你应该看起来像...
keyboard notification
NSRect: {{0, 228}, {320, 252}}
keyboard notification
NSRect: {{0, 264}, {320, 216}}
keyboard notification
NSRect: {{0, 228}, {320, 252}}
keyboard notification
NSRect: {{0, 264}, {320, 216}}
keyboard notification
NSRect: {{0, 228}, {320, 252}}
关于ios - 检查 iOS 键盘中是否存在单词建议/词典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21850306/