根据View找控制器

- (UIViewController*)viewController
{
    for (UIView* next = [self superview]; next; next = next.superview) {
        UIResponder* nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController*)nextResponder;
        }
    }
    return nil;
}

 

posted @ 2014-09-05 18:45  在路上de 小白  阅读(104)  评论(0编辑  收藏  举报