Skip to content

tabbar项大于5时,qmui_visibleViewControllerIfExist判断错误 #75

@19aneng

Description

@19aneng

运行环境

  • iOS 设备:iPhone / iPad / 模拟器
  • 系统版本:iOS 10.x
  • Xcode 版本:8.x
  • QMUI iOS 版本:1.x.x

具体问题描述

当tab的item大于5,并且tab的selectedIndex大于等于5的时候,系统把子项强行放到了moreNavigationController,导致获取selectedViewController的navVC里面的viewControllers为0

  • (UIViewController *)qmui_visibleViewControllerIfExist {

    if (self.presentedViewController) {
    return [self.presentedViewController qmui_visibleViewControllerIfExist];
    }

    if ([self isKindOfClass:[UINavigationController class]]) {
    return [((UINavigationController *)self).visibleViewController qmui_visibleViewControllerIfExist];
    }

    if ([self isKindOfClass:[UITabBarController class]]) {
    UITabBarController *tab = (UITabBarController *)self;
    if (tab.selectedIndex >= 4 && tab.customizableViewControllers.count > 5) {
    // 当tab的item大于5,并且tab的selectedIndex大于等于5的时候,系统把子项强行放到了moreNavigationController,导致获取selectedViewController的navVC里面的viewControllers为0
    return [tab.moreNavigationController qmui_visibleViewControllerIfExist];
    }else{
    return [((UITabBarController *)self).selectedViewController qmui_visibleViewControllerIfExist];
    }
    }

    if ([self qmui_isViewLoadedAndVisible]) {
    return self;
    } else {
    QMUILog(@"UIViewController (QMUI)", @"qmui_visibleViewControllerIfExist:,找不到可见的viewController。self = %@, self.view = %@, self.view.window = %@", self, [self isViewLoaded] ? self.view : nil, [self isViewLoaded] ? self.view.window : nil);
    return nil;
    }
    }

问题截图

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions