小编Gil*_*Gil的帖子

UIKeyboardWillShowNotification与ios 11 beta 7有关

在iOS 11 beta 7上测试我的应用程序 - 如果我的UIViewController,键盘似乎没有推高内容.

代码看起来像这样(从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];
    }];
}
Run Code Online (Sandbox Code Playgroud)

}

有趣的是 - 当我按下主页按钮(最小化应用程序)并重新打开它(没有杀死它)时 - 布局是固定的.

它似乎是一个iOS 11测试版的bug,但到目前为止我找不到它的任何引用. …

keyboard objective-c ios ios11

6
推荐指数
1
解决办法
2065
查看次数

标签 统计

ios ×1

ios11 ×1

keyboard ×1

objective-c ×1