IQ Keyboard Manager usage causes UI Navigation Controller navigation controller to shift abnormally

Keywords: iOS

The IQ Keyboard Manager component facilitates the switching of multiple edit controls. But in use, there is also a problem that can cause UINavigation Controller to move.

The problem can be solved by setting "self.view = [[UIScrollView alloc] initWithFrame:self.view.bounds]". But I don't know which version to start with.

(Now I'm using the latest version 4.0.8 anyway), and this setup solution won't work and will still cause UI Navigation Controller to shift.

Use UI Navigation Controller Shift


To solve this problem, there are two solutions

Scheme 1 uses the original low version. For example, 3.2.0.3

(1) Modify the version number of IQ Keyboard Manager

platform :ios, '8.0'
target:DemoIQKeyboard do
#pod 'IQKeyboardManager', '~> 4.0.8'
pod 'IQKeyboardManager', '~> 3.2.0.3'
end
(2) Set the type of edit control page to UIScrollView

- (void)loadView
{
    [super loadView];
    self.view = [[UIScrollView alloc] initWithFrame:self.view.bounds];
}
Solution 1 uses the features of the new version, but it is good for fixing UI Navigation Controller shift.

Use Effect Chart (Amended by Scheme 1)


Scheme 2 continues to use the latest version while modifying the source code

(1) An edited page, which is set to UIScrollView type. view as view Controller

- (void)loadView
{
    [super loadView];
    self.view = [[UIScrollView alloc] initWithFrame:self.view.bounds];
}

(2) Modify the method "- (UIViewController*)topMostController" in the IQUIWindow+Hierarchy.m file of IQ Keyboard Manager

- (UIViewController*)topMostController
{
    // Original code
//    UIViewController *topController = [self rootViewController];
//    
//    //  Getting topMost ViewController
//    while ([topController presentedViewController])	topController = [topController presentedViewController];
//	
//    //  Returning topMost ViewController
//    return topController;
    
    // Modify the descendant code
    UIViewController *topController = [self rootViewController];
    if ([topController isKindOfClass:[UITabBarController class]])
    {
        UITabBarController *tabbarController = (UITabBarController *)topController;
        topController = tabbarController.selectedViewController;
        if ([topController isKindOfClass:[UINavigationController class]])
        {
            UINavigationController *navController = (UINavigationController *)topController;
            topController = navController.visibleViewController;
        }
    }
    //  Getting topMost ViewController
    while ([topController presentedViewController])
    {
        topController = [topController presentedViewController];
    }
    
    //  Returning topMost ViewController
    return topController;
}

Scheme 2 corrects that UINavigation Controller will not shift, but there is a minor defect, that is, the editing control that enters the editing state for the first time, and the control will not be displayed on the keyboard immediately when it is occluded by the keyboard, but will be displayed on the keyboard only by clicking the switch button on the keyboard.

Use Effect Chart (Amended by Scheme 2)



Posted by wannasub on Sun, 07 Jul 2019 18:57:13 -0700