Keyboard layout without animation when used in UIWindow with windowLevel larger than UIWindowLevelAlert

I am currently introducing a security code view controller that contains a UITextField in which the user must enter a password. This security code view controller is presented in its own window, which has "windowLevel = UIWindowLevelAlert + 1;" because I want to hide the potential UIAlertView or other windows that may already be present.

The problem occurs when I call the resignFirstResponder method in a text field, it seems that the keyboard is rejected without the usual animation. I tried registering for various keyboard notifications and checking the UIView areAnimationsEnabled property and returns YES.

So, if someone already had this problem, you can :)

+4
source share
1 answer

UIKeyboardAnimationDurationUserInfoKey is a constant string identifier for the duration of the animation, so you can enable or disable the animation.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willHideKeyboard:) name:UIKeyboardWillHideNotification object:nil]; - (void)willHideKeyboard:(NSNotification *)notification { [UIView setAnimationsEnabled:NO]; } 
+5
source

Source: https://habr.com/ru/post/1501024/


All Articles