• IQKeyboardManager 在iOS11导航栏消失的问题


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

    解决办法: 

    找到IQUIView_Hierarchy.m   修改-(UIViewController *)topMostController方法  

    -(UIViewController *)topMostController
    {
        NSMutableArray<UIViewController*> *controllersHierarchy = [[NSMutableArray alloc] init];
        
        UIViewController *topController = self.window.rootViewController;
        
        if (topController)
        {
            [controllersHierarchy addObject:topController];
        }
        
        while ([topController presentedViewController]) {
            
            topController = [topController presentedViewController];
            [controllersHierarchy addObject:topController];
        }
        
        UIViewController *matchController = [self viewController];
        
        while (matchController != nil && [controllersHierarchy containsObject:matchController] == NO)
        {
            do
            {
                matchController = (UIViewController*)[matchController nextResponder];
                
            } while (matchController != nil && [matchController isKindOfClass:[UIViewController class]] == NO);
        }
        
        return (UIViewController*)matchController;
    }
    

    -(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;
        }
    }
    
     

     

  • 相关阅读:
    Java基础总结--常用类以及包的访问权限
    Java基础总结--多线程总结2
    关于技术太多造成选择困难/浮躁的心情应对
    Java基础总结--多线程总结1
    研究生毕业目标以及具体路线
    Java基础总结--异常处理机制
    Java基础总结--面向对象2
    【Mac系统 + Python + Django】之开发一个发布会系统【Django视图(二)】
    【Mac系统 + Python + Django】之搭建第一个【Django Demo(一)】
    【Python + ATX】之uiautomator2 PageObject模式自动化框架学习
  • 原文地址:https://www.cnblogs.com/Ganggang888/p/8709777.html
Copyright © 2020-2023  润新知