iOS开发在View中获取当前控制器

废话不多说直接上代码
- (UIViewController *)CurrentController
{
    UIResponder *responder = [self nextResponder];
    while (responder) {
        if ([responder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)responder;
        }
        responder = [responder nextResponder];
    }
    return nil;
}

你可能感兴趣的:(iOS开发在View中获取当前控制器)