开发者

How to disable a UITextField keyboard without hiding it?

开发者 https://www.devze.com 2023-03-04 09:54 出处:网络
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 cal

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消