美文网首页
视图寻找其所在的ViewController

视图寻找其所在的ViewController

作者: KKFantasy | 来源:发表于2016-04-19 23:45 被阅读0次
- (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;
}

相关文章

网友评论

      本文标题:视图寻找其所在的ViewController

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