当用户可以使用键盘时,会正确广播通知UIKeyboardWillShowNotification
。
发生这种情况时我调用了我的委托方法,但我怎么知道它是否是蓝牙键盘?
感谢
更新
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification
object:nil];
答案 0 :(得分:0)
如果存在蓝牙键盘,则不会广播该通知(UIKeyboardWillShowNotification),除非您有inputAccessoryView。事实上,这是了解的唯一方法。如果您使用它来调整软件键盘的视图,您应该根据此通知处理它,您将始终没问题。
否则,您可以检查通知的userInfo属性中的键盘大小差异。
答案 1 :(得分:0)
这些信息可以在userInfo字典中找到,它只需要一些操作来获得你想要的东西。
NSDictionary *userInfo = [aNotification userInfo];
CGRect startKeyboardRect = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect finishKeyboardRect = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
startKeyboardRect = [self.view convertRect:startKeyboardRect fromView:self.view.window];
finishKeyboardRect = [self.view convertRect:finishKeyboardRect fromView:self.view.window];
CGFloat vertShuffle = startKeyboardRect.origin.y - finishKeyboardRect.origin.y;