UIKeyboardWillShowNotification与ios 11 beta 7有关 [英] UIKeyboardWillShowNotification issues with ios 11 beta 7
问题描述
在iOS 11 beta 7上测试我的应用程序 - 如果我的UIViewController,键盘似乎没有推高内容。
Testing my app on iOS 11 beta 7 - it seems like the keyboard doesn't push up the content if my UIViewController.
代码如下(从iOS7开始工作):
The code looks like this (working since iOS7):
- (void)handleNotification:(NSNotification*)notification {
if (notification.name == UIKeyboardWillShowNotification) {
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
nextButtonALBottomDistance.constant = keyboardSize.height + initialPhoneBottomDistance;
codeBottomViewALBottomDistance.constant = keyboardSize.height + initialCodeBottomDistance;
double animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:animationDuration animations:^{
[self.view layoutIfNeeded];
}];
}
else if (notification.name == UIKeyboardWillHideNotification) {
nextButtonALBottomDistance.constant = initialPhoneBottomDistance;
codeBottomViewALBottomDistance.constant = initialCodeBottomDistance;
double animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:animationDuration animations:^{
[self.view layoutIfNeeded];
}];
}
}
有趣的是 - 当我按下主页按钮(最小化应用程序)并重新打开它(没有杀死它)时 - 布局是固定的。
Interesting enough - when I press the home button (minimizing the app) and reopening it (without killing it) - the layout is fixed.
这似乎是iOS 11测试版的错误,但到目前为止我找不到任何引用。
It seems like an iOS 11 beta bug, but I couldn't find any reference to it so far.
很高兴知道其他人是否有这个问题。
Happy to know if someone else is having this issue.
推荐答案
使用 UIKeyboardFrameEndUserInfoKey ,因为该键用于包含CGRect的NSValue对象,该CGRect在屏幕坐标中标识键盘的结束帧。 不使用UIKeyboardFrameBeginUserInfoKey 。
Use UIKeyboardFrameEndUserInfoKey because that key is for the NSValue object containing a CGRect that identifies an end frame of the keyboard in screen coordinates. Do not use UIKeyboardFrameBeginUserInfoKey.
这篇关于UIKeyboardWillShowNotification与ios 11 beta 7有关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!