Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
19aneng opened this issue Jun 20, 2022 · 0 comments
Open
4 tasks done

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

19aneng opened this issue Jun 20, 2022 · 0 comments
Labels

Comments

@19aneng
Copy link

19aneng commented Jun 20, 2022

运行环境

  • 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

@MoLice MoLice added the bug label Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants