美文网首页固予iOS
ios收到推送时视图跳转的处理 -- 获取当前视图控制器

ios收到推送时视图跳转的处理 -- 获取当前视图控制器

作者: 贺乾龙 | 来源:发表于2016-11-08 14:58 被阅读437次

相关文章

网友评论

  • 时光浅影:要复制的,拿去不谢!

    UIViewController *currVC = nil;
    UIViewController * RootVC = self.window.rootViewController;
    do {
    if ([RootVC isKindOfClass:[UINavigationController class]]) {
    UINavigationController * nav = (UINavigationController*)RootVC;
    UIViewController * v = [nav.viewControllers lastObject];
    currVC = v;
    RootVC = v.presentedViewController;
    continue;
    }else if ([RootVC isKindOfClass:[UITabBarController class]]){
    UITabBarController * tabVC = (UITabBarController *) RootVC;
    currVC = tabVC;
    RootVC = [tabVC.viewControllers objectAtIndex:tabVC.selectedIndex];
    continue;
    }
    } while (RootVC!=nil);
    return currVC;
  • 好有魔力:这个代码在程序当前显示的present出来的viewController的时候会不会死循环?
    是秋天阿:我覺得會啊,你試過嗎
  • ZfRee:不枉我跟着你的思路手敲一遍 可以的
  • 酷哥不回头看爆炸:简主。你的代码怎么是个图片,我想复制过去用呢。

本文标题:ios收到推送时视图跳转的处理 -- 获取当前视图控制器

本文链接:https://www.haomeiwen.com/subject/rwxiuttx.html