Skip to content

Commit

Permalink
fix action menu show problem
Browse files Browse the repository at this point in the history
  • Loading branch information
lilthree committed Jun 3, 2018
1 parent 1d78639 commit a4c589a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions common/Classes/UIViewController+Extend.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@
- (BOOL)checkNetworkStatus;

- (void)popupTwoStepVerificationViewHandler:(void (^)(NSString *input,BOOL remember))handler;

- (UIViewController *)topViewControllerIn:(UIViewController*)rootViewRootVC;
@end
21 changes: 21 additions & 0 deletions common/Classes/UIViewController+Extend.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,25 @@ - (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
5 changes: 3 additions & 2 deletions seafile/SeafFileViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,9 @@ - (void)showSheetWithTitles:(NSArray*)titles andFromView:(id)view

[actionSheet showFromPoint:point inView:self.navigationController.view arrowDirection:SFActionSheetArrowDirectionTop animated:YES];
} else {
UIView *topView = [[[UIApplication sharedApplication] keyWindow].subviews firstObject];
[actionSheet showInView:topView animated:YES];
UIViewController *topVC = [self topViewControllerIn:[[[[UIApplication sharedApplication] delegate] window] rootViewController]];

[actionSheet showInView:topVC.view.window animated:YES];
}
}

Expand Down

0 comments on commit a4c589a

Please sign in to comment.