找到当前视图的父视图控制器

//找到当前视图的父视图控制器

- (UIViewController *)getViewController

{

    for (UIView *next = [self superview];next;next = [next superview]) {

        UIResponder *responder = [next nextResponder];

        if ([responder isKindOfClass:[UIViewController class]]) {

            return (UIViewController *)responder;

        }

    }

    returnnil;

}

posted on 2014-01-08 00:20  IOS开发者  阅读(390)  评论(0编辑  收藏  举报