IOS进入后台,取消键盘响应

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    //进入后台,取消一切键盘响应(循环两层,)
    NSArray *windows =  [[UIApplication sharedApplication] windows];
    UIWindow *mainWindow = [windows objectAtIndex:0];
    
    for (UIView * subView in mainWindow.subviews) {
        [subView endEditing:NO];
        for (UIView * subSubView in subView.subviews) {
            [subSubView endEditing:NO];
        }
    }
}

你可能感兴趣的:(IOS进入后台,取消键盘响应)