阅读 99

UIView 直接push的方法

朋友介绍的 很好用

.h

#import

@interface HXGetTheViewController : NSObject

+ (UIViewController *)getNowViewController;

@end

.m

+ (UIViewController *)getNowViewController {

    UIViewController * getVc = [UIApplication sharedApplication].keyWindow.rootViewController;

    while(1) {

        //根据不同的页面切换方式,逐步取得最上层的viewController

        if ([getVc isKindOfClass:[UITabBarController class]]) {

            getVc = ((UITabBarController *)getVc).selectedViewController;

        }

        if ([getVc isKindOfClass:[UINavigationController class]]) {

            getVc = ((UINavigationController *)getVc).visibleViewController;

        }

        if (getVc.presentedViewController) {

            getVc = getVc.presentedViewController;

        }else{

            break;

        }

    }

    returngetVc;

}

调用

FindPasswordViewController *joinVC = [FindPasswordViewController new];

    UIViewController *getVC = [HXGetTheViewController getNowViewController];

    joinVC.type=1;

    [getVC.navigationController pushViewController:joinVC animated:YES];

作者:只会写bug啊

原文链接:https://www.jianshu.com/p/5b4c0739d086

文章分类
后端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐