Ver código fonte

Fix dismissAllModal API - the root won't unregister when invoke dismissAllModals (#2255)

Ran Greenberg 7 anos atrás
pai
commit
b0eeeccf36
Nenhuma conta vinculada ao e-mail do autor do commit
1 arquivos alterados com 7 adições e 1 exclusões
  1. 7
    1
      ios/RCCManagerModule.m

+ 7
- 1
ios/RCCManagerModule.m Ver arquivo

@@ -142,6 +142,8 @@ RCT_EXPORT_MODULE(RCCManager);
142 142
 
143 143
 -(void)dismissAllModalPresenters:(NSMutableArray*)allPresentedViewControllers resolver:(RCTPromiseResolveBlock)resolve
144 144
 {
145
+    UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
146
+
145 147
     if (allPresentedViewControllers.count > 0)
146 148
     {
147 149
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^
@@ -151,7 +153,7 @@ RCT_EXPORT_MODULE(RCCManager);
151 153
                            {
152 154
                                counter++;
153 155
                                
154
-                               [[RCCManager sharedIntance] unregisterController:viewController];
156
+                               
155 157
                                if (viewController.presentedViewController != nil)
156 158
                                {
157 159
                                    dispatch_semaphore_t dismiss_sema = dispatch_semaphore_create(0);
@@ -160,6 +162,10 @@ RCT_EXPORT_MODULE(RCCManager);
160 162
                                                   {
161 163
                                                       [viewController dismissViewControllerAnimated:NO completion:^()
162 164
                                                        {
165
+                                                           if (rootViewController != viewController) {
166
+                                                               [[RCCManager sharedIntance] unregisterController:viewController];
167
+                                                           }
168
+                                                           
163 169
                                                            if (counter == allPresentedViewControllers.count && allPresentedViewControllers.count > 0)
164 170
                                                            {
165 171
                                                                [allPresentedViewControllers removeAllObjects];