diff options
Diffstat (limited to 'Juick/Helpers')
-rw-r--r-- | Juick/Helpers/User+UIView.h | 2 | ||||
-rw-r--r-- | Juick/Helpers/User+UIView.m | 13 |
2 files changed, 7 insertions, 8 deletions
diff --git a/Juick/Helpers/User+UIView.h b/Juick/Helpers/User+UIView.h index d2f75ce..dcd7047 100644 --- a/Juick/Helpers/User+UIView.h +++ b/Juick/Helpers/User+UIView.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @interface User (UIView) -+ (void) throwUnableToLogin:(UIViewController *)view error:(NSError *)error path:(NSString *)path params:(NSDictionary * _Nullable)params; ++ (void) throwUnableToLogin:(UIViewController *)parentViewController sourceView:(UIView *)sourceView error:(NSError *)error path:(NSString *)path params:(NSDictionary * _Nullable)params; @end diff --git a/Juick/Helpers/User+UIView.m b/Juick/Helpers/User+UIView.m index 4fb0bc3..2235cef 100644 --- a/Juick/Helpers/User+UIView.m +++ b/Juick/Helpers/User+UIView.m @@ -10,19 +10,18 @@ @implementation User (UIView) -+(void) throwUnableToLogin:(UIViewController *)view error:(NSError *)error path:(NSString *)path params:(NSDictionary *)params { ++(void) throwUnableToLogin:(UIViewController *)parentViewController sourceView:(UIView *)sourceView error:(NSError *)error path:(NSString *)path params:(NSDictionary *)params { UIAlertController *alert = [UIAlertController new]; NSString *title = error.userInfo[@"url"] ? error.userInfo[@"url"] : @"Something went wrong"; [alert setTitle:title]; [alert setMessage:[NSString stringWithFormat:@"err: %@, path: %@, params: %@", error.localizedDescription, path, params]]; [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]]; - UIPopoverPresentationController *popover = [alert popoverPresentationController]; - if (popover) { - popover.sourceView = view.view; - popover.sourceRect = CGRectMake(CGRectGetMidX(view.view.bounds), CGRectGetMidY(view.view.bounds), 0, 0); - popover.permittedArrowDirections = UIPopoverArrowDirectionDown; + UIPopoverPresentationController *popopverPresenter = [alert popoverPresentationController]; + if (popopverPresenter) { + popopverPresenter.sourceView = sourceView; + popopverPresenter.sourceRect = CGRectMake(CGRectGetMidX(sourceView.bounds), CGRectGetMidY(sourceView.bounds), 0, 0); } - [view presentViewController:alert animated:YES completion:nil]; + [parentViewController presentViewController:alert animated:YES completion:nil]; } @end |