在窗口级别大于UIWindowLevelAlert的UIWindow中使用键盘时不使用动画

Lio*_*hAu 4 iphone keyboard objective-c uiwindow ios

我目前正在展示一个安全代码视图控制器,它包含一个UITextField,用户应在其中输入密码.此安全代码视图控制器显示在其自己的窗口中,该窗口具有"windowLevel = UIWindowLevelAlert + 1;" 因为我想隐藏潜在的UIAlertView或其他可能已经显示的窗口.

当我在文本字段上调用resignFirstResponder方法时出现问题,似乎键盘在没有通常动画的情况下被解除.我尝试注册各种键盘通知,并检查了UIView areAnimationsEnabled属性,它返回YES.

所以,如果有人已经有这个问题,欢迎你:)

小智 5

UIKeyboardAnimationDurationUserInfoKey是动画持续时间的常量字符串标识符,因此可以在其中启用和禁用动画.

[[NSNotificationCenter defaultCenter] addObserver:self 
                                     selector:@selector(willHideKeyboard:) 
                                         name:UIKeyboardWillHideNotification 
                                       object:nil];

- (void)willHideKeyboard:(NSNotification *)notification {
       [UIView setAnimationsEnabled:NO];
  }
Run Code Online (Sandbox Code Playgroud)