相关疑难解决方法(0)

keyboardWillShow调用了两次

我有一个键盘通知,如keyboardWillShowkeyboardWillHide

我使用的通知处理的所有代码都取自Apple的示例代码"KeyboardAccessory"

当我第一次进入这个视图时,一切正常.

但是当我从子视图返回到此视图时,每次我点击一个按钮说:

[myTextField becomeFirstResponder];
Run Code Online (Sandbox Code Playgroud)

keyboardWillShowkeyboardWillHide方法都需要进行两次,每次调用.

这真的令人困惑,

任何人都可以帮助我吗?

万分感激!

iphone notifications nsnotifications uiresponder ios

9
推荐指数
3
解决办法
7892
查看次数

在IOS8中使用UIKeyboardWillShowNotification的keyboardWillShow

我在IOS 7和IOS 8设备上运行相同的代码,结果不同

给定一个带有两个文本字段的屏幕

在IOS 7中,如果我触摸第一个字段,则键盘会被调用,但是如果我在键盘已经显示时触摸第二个字段,则不再调用第二个字段.

在IOS 8中,keyboardWillShow被调用两次

这是记录在案的行为?

ios

7
推荐指数
1
解决办法
4765
查看次数

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
查看次数