소스 검색

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

Ran Greenberg 7 년 전
부모
커밋
b0eeeccf36
No account linked to committer's email address
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7
    1
      ios/RCCManagerModule.m

+ 7
- 1
ios/RCCManagerModule.m 파일 보기

@@ -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];