From c8fb2ef977a7d43b0ff62fc695927bee20a7f2a4 Mon Sep 17 00:00:00 2001 From: AKanjariya Date: Wed, 21 Mar 2018 16:05:16 +0530 Subject: [PATCH] Presenting webview issue fixed In previous code, if any controller is already presented on rootViewController then it won't present another one. In this fix, If Any controller is already presented then we present webview on presentedViewController rather than RootViewController. --- IOSLinkedInAPI/LIALinkedInHttpClient.m | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/IOSLinkedInAPI/LIALinkedInHttpClient.m b/IOSLinkedInAPI/LIALinkedInHttpClient.m index e7ed9dc..95e0e78 100755 --- a/IOSLinkedInAPI/LIALinkedInHttpClient.m +++ b/IOSLinkedInAPI/LIALinkedInHttpClient.m @@ -133,16 +133,22 @@ - (void)getAuthorizationCode:(void (^)(NSString *))success cancel:(void (^)(void } - (void)showAuthorizationView:(LIALinkedInAuthorizationViewController *)authorizationViewController { - if (self.presentingViewController == nil) - self.presentingViewController = [[UIApplication sharedApplication] keyWindow].rootViewController; - - UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:authorizationViewController]; - - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { - nc.modalPresentationStyle = UIModalPresentationFormSheet; - } - - [self.presentingViewController presentViewController:nc animated:YES completion:nil]; + if (self.presentingViewController == nil) { + UIViewController *rootVC = [[UIApplication sharedApplication] keyWindow].rootViewController; + if (rootVC.presentedViewController == nil) { + self.presentingViewController = rootVC; + } else { + self.presentingViewController = rootVC.presentedViewController; + } + } + + UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:authorizationViewController]; + + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + nc.modalPresentationStyle = UIModalPresentationFormSheet; + } + + [self.presentingViewController presentViewController:nc animated:YES completion:nil]; } - (void)hideAuthenticateView {