开发者

How to disable a UITextField keyboard without hiding it?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜