#pragma mark 获得当前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;
}
用的时候,直接调用此方法就可以
[[self viewController] presentViewController:alertController animated:YES completion:nil];