diff --git a/common/Classes/UIViewController+Extend.h b/common/Classes/UIViewController+Extend.h index 7fab500a..b186502c 100644 --- a/common/Classes/UIViewController+Extend.h +++ b/common/Classes/UIViewController+Extend.h @@ -36,6 +36,4 @@ - (BOOL)checkNetworkStatus; - (void)popupTwoStepVerificationViewHandler:(void (^)(NSString *input,BOOL remember))handler; - -- (UIViewController *)topViewControllerIn:(UIViewController*)rootViewRootVC; @end diff --git a/common/Classes/UIViewController+Extend.m b/common/Classes/UIViewController+Extend.m index 714ef478..f23ec5de 100644 --- a/common/Classes/UIViewController+Extend.m +++ b/common/Classes/UIViewController+Extend.m @@ -236,25 +236,4 @@ - (BOOL)checkNetworkStatus return YES; } -#pragma mark topViewController -- (UIViewController *)topViewControllerIn:(UIViewController*)rootViewRootVC { - UIViewController *topVC; - topVC = [self findTopViewController:rootViewRootVC]; - while (topVC.presentedViewController) { - topVC = [self findTopViewController:topVC.presentedViewController]; - } - return topVC; -} - -- (UIViewController *)findTopViewController:(UIViewController *)vc { - if ([vc isKindOfClass:[UINavigationController class]]) { - return [self findTopViewController:[(UINavigationController *)vc topViewController]]; - } else if ([vc isKindOfClass:[UITabBarController class]]) { - return [self findTopViewController:[(UITabBarController *)vc selectedViewController]]; - } else { - return vc; - } - return nil; -} - @end diff --git a/seafile/SeafAppDelegate.h b/seafile/SeafAppDelegate.h index 8ba970bf..a8dbf1d8 100644 --- a/seafile/SeafAppDelegate.h +++ b/seafile/SeafAppDelegate.h @@ -73,6 +73,7 @@ enum { - (void)stopSignificantChangeUpdates; - (void)checkBackgroundUploadStatus; ++ (UIViewController *)topViewController; + (void)checkOpenLink:(SeafFileViewController *)c; @end diff --git a/seafile/SeafAppDelegate.m b/seafile/SeafAppDelegate.m index d487a823..6ea46ade 100644 --- a/seafile/SeafAppDelegate.m +++ b/seafile/SeafAppDelegate.m @@ -681,4 +681,30 @@ - (void)onResp:(BaseResp *)resp { } } +#pragma mark topViewController ++ (UIViewController *)topViewController { + SeafAppDelegate *delegate = (SeafAppDelegate*)[UIApplication sharedApplication].delegate; + return [delegate topViewController]; +} + +- (UIViewController *)topViewController { + UIViewController *rootVC = [self.window rootViewController]; + UIViewController *topVC = [self findTopViewController:rootVC]; + while (topVC.presentedViewController) { + topVC = [self findTopViewController:topVC.presentedViewController]; + } + return topVC; +} + +- (UIViewController *)findTopViewController:(UIViewController *)vc { + if ([vc isKindOfClass:[UINavigationController class]]) { + return [self findTopViewController:[(UINavigationController *)vc topViewController]]; + } else if ([vc isKindOfClass:[UITabBarController class]]) { + return [self findTopViewController:[(UITabBarController *)vc selectedViewController]]; + } else { + return vc; + } + return nil; +} + @end diff --git a/seafile/SeafFileViewController.m b/seafile/SeafFileViewController.m index dab57458..dd29c39b 100644 --- a/seafile/SeafFileViewController.m +++ b/seafile/SeafFileViewController.m @@ -674,9 +674,7 @@ - (void)showSheetWithTitles:(NSArray*)titles andFromView:(id)view [actionSheet showFromPoint:point inView:self.navigationController.view arrowDirection:SFActionSheetArrowDirectionTop animated:YES]; } else { - UIViewController *topVC = [self topViewControllerIn:[[[[UIApplication sharedApplication] delegate] window] rootViewController]]; - - [actionSheet showInView:topVC.view.window animated:YES]; + [actionSheet showInView:[SeafAppDelegate topViewController].view.window animated:YES]; } }