ios - 检查 iOS 键盘中是否存在单词建议/词典

标签 ios iphone keyboard uikeyboardtype

如何检查我的 iOS 键盘是否显示字典或单词建议(我不知道正确的术语)。

enter image description here

我在网上搜索过,但没有找到答案。 在那些单词建议/字典后面是我的输入字段,但是当单词建议/字典出现时它被隐藏在它后面。我希望我的输入在出现建议/词典时动态地将其放在单词建议/字典的顶部。为此,只要出现单词建议/字典,我只需要一个通知。有人知道怎么做吗?

最佳答案

我也不知道建议栏术语是什么...

但是你可以使用 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/

相关文章:

ios - Firebase 安全和规则

iOS:事件指示器停止后如何执行一段代码?

iphone - 使用 CoreData 创建新闻提要

python - 从关键事件中获取特殊字符

ios - hitTest 关闭导致奇怪行为的键盘

ios - 在 UITabBarController 内的 View Controller 之间传递数据,无需使用 segues

objective-c - ios mapkit 通过点击 map 关闭注释标注

iphone - 如何确定哪个控件触发了事件?

iphone - iOS程序中如何释放使用copy关键字的对象

windows-phone-7 - 键盘可以有完成和取消按钮吗?