IQKeyboardManager 在iOS11系统下使得导航栏的背景颜色无法渗透电池栏而出现分节。且导致表格内容区上移等问题。如下图:
问题原因:IQKeyboardManager 在获取当前顶层控制器的时候获取到了tabBarController 。
解决方案:找到IQKeyboardManager框架中IQUIView+Hierarchy.m文件修改-(UIViewController*)topMostController 方法中的代码。实现如下:
-(UIViewController*)topMostController{
UIViewController *rootController = [UIApplication sharedApplication].keyWindow.rootViewController;
if([rootController isKindOfClass:[UITabBarController class]]){
UITabBarController *tabBarController = (UITabBarController*)rootController;
UINavigationController*navController = tabBarController.selectedViewController;
UIViewController*viewController = (UIViewController*)navController.visibleViewController;
while(viewController.presentedViewController) {
viewController = (UIViewController*)viewController.presentedViewController;
}
return viewController;
}else if([rootController isKindOfClass:[UINavigationController class]]) {
UINavigationController *navController = (UINavigationController*)rootController;
return navController.visibleViewController;
}else if([rootController isKindOfClass:[UIViewController class]]) {
return rootController;
} else{
return nil;
}
}