关于IQKeyboardManager 在iOS11导航栏消失的问题

关于IQKeyboardManager 在iOS11导航栏消失的问题

问题:  升级到iOS11之后点击键盘时导航栏消失 如下图:

使用版本:pod 'IQKeyboardManager', '~> 5.0.6'


问题原因:IQKeyboardManager 在获取当前顶层控制器的时候获取到了tabBarController 

解决办法: 

找到IQUIView_Hierarchy.m   修改-(UIViewController *)topMostController方法  如下:即可

-(UIViewController *)topMostController{

    UIViewController *rootController = [UIApplication sharedApplication].keyWindow.rootViewController;

    if([rootController isKindOfClass:[UITabBarController class]]){
        UITabBarController *tabBarController = (UITabBarController *)rootController;
        UINavigationController *selectController = tabBarController.selectedViewController;
        UIViewController *viewController = (UIViewController *)selectController.visibleViewController;
        while (viewController.presentedViewController) {
            viewController = (UIViewController *)viewController.presentedViewController;
        }
        
        return viewController;
    }else if ([rootController isKindOfClass:[UINavigationController class]]) {
        UINavigationController *selectController = (UINavigationController *)rootController;
        return selectController.visibleViewController;
    }else if ([rootController isKindOfClass:[UIViewController class]]) {
            return rootController;
    }
    else{
        return nil;
    }
 }



关于IQKeyboardManager 在iOS11导航栏消失的问题_第1张图片关于IQKeyboardManager 在iOS11导航栏消失的问题_第2张图片









你可能感兴趣的:(iOS)