I have an animation, during which I want to disable the keyboard but not hide it. I even tried self.view.userInteractionEnabled = NO;
, but that hides the keyboard开发者_如何学JAVA. I guess it must call resignFirstResponder
.
To disable everything, you can use
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
right before you start the animation and
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
after the animation finishes, e.g., in its completion block.
You can disable the keyboard without dismissing it by doing:
NSArray *windows = [UIApplication sharedApplication].windows;
if ([windows count] > 1) {
UIWindow *keyboardWindow = windows[1];
keyboardWindow.userInteractionEnabled = NO;
}
But, it's obviously very hackish & fragile, and I'm not sure if it complies with Apple's terms.
精彩评论