1***@qq.com
1***@qq.com
  • 发布:2024-12-19 11:21
  • 更新:2024-12-19 11:21
  • 阅读:39

ios原生组件插件 跳转原生页面,有什么办法吗

分类: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;    
}

目前使用这个跳转原生页面,效果不是很好,有什么好的方法吗

2024-12-19 11:21 负责人:无 分享
已邀请:

要回复问题请先登录注册