#pragma mark - other
-(UIViewController *)viewController {
for(UIView* next =[self.view superview];next;next = next.superview){
UIResponder *nextResponder =[next nextResponder];
if([nextResponder isKindOfClass:[UIViewController class]]){
return(UIViewController *)nextResponder;
}
}
return[self getTopController];
}
-(UIViewController *)getTopController{
UIViewController *topController =[UIApplication sharedApplication].keyWindow.rootViewController;
while(topController.presentedViewController){
topController = topController.presentedViewController;
}
return topController;
}
网友评论