iOS tip(3)

2016-01-07  本文已影响14人  DevYu

获取UIView所在的控制器,代码示例如下:

- (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;
}
上一篇下一篇

猜你喜欢

热点阅读