码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 之 获取View所在控制器

时间:2015-12-21 18:29:23      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

1. UIResponder

UIViewController *uvc;
    UIResponder* nextResponder = [self.superview.superview.superview nextResponder];
    
    if ([nextResponder isKindOfClass:[UIViewController class]]) {
        uvc = (UIViewController*)nextResponder;
    }

2.获取当前屏幕中present出来的viewcontroller

- (UIViewController *)getPresentedViewController
{
    UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
    UIViewController *topVC = appRootVC;
    if (topVC.presentedViewController) {
        topVC = topVC.presentedViewController;
    }
    
    return topVC;
}

 

iOS 之 获取View所在控制器

标签:

原文地址:http://www.cnblogs.com/SimonGao/p/5063944.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!