1***@163.com
1***@163.com
  • 发布:2023-06-25 16:35
  • 更新:2023-06-25 17:25
  • 阅读:248

iOS 插件 怎样才能使用pushViewController跳转下一个页面呢?

分类:uni-app

// 获取当前显示的 UIViewController

  • (UIViewController )dc_findCurrentShowingViewController {
    //获得当前活动窗口的根视图
    UIViewController
    vc = [UIApplication sharedApplication].keyWindow.rootViewController;
    UIViewController *currentShowingVC = [self findCurrentShowingViewControllerFrom:vc];
    return currentShowingVC;
    }
  • (UIViewController )findCurrentShowingViewControllerFrom:(UIViewController )vc
    {
    // 递归方法 Recursive method
    UIViewController currentShowingVC;
    if ([vc presentedViewController]) {
    // 当前视图是被presented出来的
    UIViewController
    nextRootVC = [vc presentedViewController];
    currentShowingVC = [self findCurrentShowingViewControllerFrom:nextRootVC];

    } else if ([vc isKindOfClass:[UITabBarController class]]) {
    // 根视图为UITabBarController
    UIViewController nextRootVC = [(UITabBarController )vc selectedViewController];
    currentShowingVC = [self findCurrentShowingViewControllerFrom:nextRootVC];

    } else if ([vc isKindOfClass:[UINavigationController class]]){
    // 根视图为UINavigationController
    UIViewController nextRootVC = [(UINavigationController )vc visibleViewController];
    currentShowingVC = [self findCurrentShowingViewControllerFrom:nextRootVC];

    } else {
    // 根视图为非导航类
    currentShowingVC = vc;
    }

    return currentShowingVC;
    }

iOS 插件 只能获取当前的控制器 能调用presentViewController 跳转下一个页面 怎样才能使用pushViewController跳转下一个页面呢?

2023-06-25 16:35 负责人:无 分享
已邀请:
FullStack

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866

下一个页面 要包含UINavigationController,才能pushViewController

  • 1***@163.com (作者)

    ViewController vc = [ViewController new];


    UINavigationController nav = [[UINavigationController alloc] initWithRootViewController:[self dc_findCurrentShowingViewController]];  

    [nav pushViewController:vc animated:YES];

    这样写不行,请问要怎样写呢?大神

    2023-06-25 18:25

该问题目前已经被锁定, 无法添加新回复