iOS

IQKeyboardManager使用TextView导致系统导

2018-01-10  本文已影响490人  无敌大闸蟹

1 :在页面出现时关闭第三方  页面消失时再打开 单独在这个页面处理  监听 UIKeyboardWillShowNotification和UIKeyboardWillHideNotification  处理textview的frame的常规做法  
如:////监听键盘将要出现

//- (void)keyboardWillShow: (NSNotification*)notification

//{

//    CGRect keyBoardFrame = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

//    [UIView animateWithDuration:0.3 animations:^{

//        self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y - keyBoardFrame.size.height,self.frame.size.width, self.frame.size.height);

//    }];

//}

//

////监听键盘将要消失

//- (void)keyboardWillHide: (NSNotification*)notification

//{

//    [UIView animateWithDuration:0.3 animations:^{

//        self.frame = 之前的frame//    }];

//}

2:  第二种做法比较简单 针对高版本的IQKeyboardManager  
 系统搜索IQUIView+Hierarchy.h文件里的-(UIViewController*)topMostController方法
把里面的代码替换成

```

- (UIViewController*)topMostController

{

    UIViewController*topController =self.window.rootViewController;

    if([topControllerisKindOfClass:[UITabBarControllerclass]]){

        UITabBarController*tabbarController = (UITabBarController*)topController;

        topController = tabbarController.selectedViewController;

        if([topControllerisKindOfClass:[UINavigationControllerclass]]){

            UINavigationController*navController = (UINavigationController*)topController;

            topController = navController.visibleViewController;

        }

    }

    while ([topController presentedViewController])

    {

        topController = [topControllerpresentedViewController];

    }

    returntopController;

}

```

就可以了  会引出一些问题  但是一般情况下碰不到  如果有碰到了的朋友可以留言给我一起讨论下。

上一篇下一篇

猜你喜欢

热点阅读