简体   繁体   English

在iOS 4.0上强制使键盘消失

[英]Make Keyboard disappear by force on ios 4.0

When TextVIew was activated I used to make keyboard invisible on ios 3.1.3 version by using the source i wrote.(please refer to above or below my email.) but I can not make keyboard invisible any more with the source on ios 4.0. 激活TextVIew时,我曾经使用自己编写的源代码使ios 3.1.3版本上的键盘不可见(请参阅电子邮件的上方或下方。),但我无法再使ios 4.0上的源代码使键盘不可见。 Could you tell me how to make key board disappear on the ios 4.0 version ? 你能告诉我如何使键盘在ios 4.0版本上消失吗?


[[NSNotificationCenter defaultCenter] addObserver:self 
                                      selector:@selector (keyboardWillShow:) 
                                      name:UIKeyboardWillShowNotification 
                                      object:nil];


-(void)keyboardWillShow:(NSNotification *)note 
{
    for(UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) 
    {
        for(UIView *keyboard in [keyboardWindow subviews]) 
        {
            if( [[keyboard description] hasPrefix:@"<UIKeyboard"]==YES) 
            {
                [keyboard setBounds:CGRectMake(keyboard.frame.origin.x+1000, 
                                               keyboard.frame.origin.y+1000,
                                               keyboard.frame.size.width, 
                                               keyboard.frame.size.height)];
            }
        }
    }
}

为什么不辞职?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM