简体   繁体   English

键盘未隐藏在iOS 6中

[英]Keyboard not hiding in iOS 6

I'm pushing a view controller to a navigation controller and in iOS 7 when that happens the keyboard automatically hides. 我将视图控制器推到导航控制器,在iOS 7中,这种情况下键盘会自动隐藏。

However, in iOS 6, it does not. 但是,在iOS 6中则没有。 I also can't get it to go away with [self.view endEditing:YES]; 我也无法通过[self.view endEditing:YES];消除它[self.view endEditing:YES]; .

EDIT: In the preceding view controller, once the keyboard is brought up, it does not go away in that view controller with [self.view endEditing:YES] either. 编辑:在前面的视图控制器中,一旦抬起键盘,它也不会通过[self.view endEditing:YES]在该视图控制器中[self.view endEditing:YES]

You could try this: 您可以尝试以下方法:

-(void)viewWillDisappear:(BOOL)animated{

    [self performSelector:@selector(resignFirstResponder) onChildrenOfView:self.view];

}

-(void)performSelector:(SEL)selector onChildrenOfView:(UIView*)view{

    for ( UIView * subView in view.subviews ) {

        if ( [subView respondsToSelector:selector] ) {
            [subView performSelector:selector];
        }

        if ( [subView isKindOfClass:[UIView class]] ) {
            [self performSelector:selector onChildrenOfView:subView];
        }

    }

}

Sorry if it's a little verbose. 抱歉,如果有点冗长。

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

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