WQPermissionRequest icon indicating copy to clipboard operation
WQPermissionRequest copied to clipboard

其他的一个方法可能会有报错的情况

Open jiyifanzi opened this issue 7 years ago • 0 comments

  • (UIViewController *)currentViewController

这个方法,最后取值不严谨,可能存在数组越界的情况

UIView *frontV = [[window subviews] objectAtIndex:0];
id nextReqoner = [frontV nextResponder];
if ([nextReqoner isKindOfClass:[UIViewController class]]) {
    currentVC = nextReqoner;
}else {
    currentVC = window.rootViewController;
}
return currentVC;

应当改为

UIViewController *currentVC = window.rootViewController;
while (result.presentedViewController) {
    currentVC = result.presentedViewController;
}
if ([result isKindOfClass:[UITabBarController class]]) {
    currentVC = [(UITabBarController *)result selectedViewController];
}
if ([result isKindOfClass:[UINavigationController class]]) {
    currentVC = [(UINavigationController *)result topViewController];
}
return result;

等会我提交一个Pull Request

jiyifanzi avatar Aug 26 '18 08:08 jiyifanzi