From 438df8db486c96e497a4bf0c6b4743ecca997103 Mon Sep 17 00:00:00 2001 From: Chong Jiang Wei Date: Thu, 31 May 2018 14:26:54 +0800 Subject: [PATCH] Fix not opening on iOS with nested modal views The earlier fix in c3cda7fa3c07ef316f05c2aba6b5ce0f5ce532ae did not handle nested modal views. It only considered the first "level" along the stack. --- ios/RCTContactsWrapper/RCTContactsWrapper.m | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ios/RCTContactsWrapper/RCTContactsWrapper.m b/ios/RCTContactsWrapper/RCTContactsWrapper.m index 72243ca..10906aa 100644 --- a/ios/RCTContactsWrapper/RCTContactsWrapper.m +++ b/ios/RCTContactsWrapper/RCTContactsWrapper.m @@ -67,14 +67,10 @@ -(void) launchContacts { } //Launch Contact Picker or Address Book View Controller UIViewController *root = [[[UIApplication sharedApplication] delegate] window].rootViewController; - BOOL modalPresent = (BOOL) (root.presentedViewController); - if (modalPresent) { - UIViewController *parent = root.presentedViewController; - [parent presentViewController:picker animated:YES completion:nil]; - } else { - [root presentViewController:picker animated:YES completion:nil]; + while (root.presentedViewController) { + root = root.presentedViewController; } - + [root presentViewController:picker animated:YES completion:nil]; }