diff options
Diffstat (limited to 'Juick/Helpers/User+UIView.m')
-rw-r--r-- | Juick/Helpers/User+UIView.m | 13 |
1 files changed, 6 insertions, 7 deletions
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 |