iOS 关闭键盘 3种方式

1,明确知道 当前的UITextField,或者UITextView
[self.mTextField resignFirstResponder];

2.
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];

3.
[[self findFirstResponderBeneathView:self.view] resignFirstResponder];

- (UIView*)findFirstResponderBeneathView:(UIView*)view
{
    // Search recursively for first responder
    for ( UIView *childView in view.subviews ) {
        if ( [childView respondsToSelector:@selector(isFirstResponder)] && [childView isFirstResponder] )
            return childView;
        UIView *result = [self findFirstResponderBeneathView:childView];
        if ( result )
            return result;
    }
    return nil;
}

你可能感兴趣的:(ios)