Selaa lähdekoodia

Fix pageSheet modals causing memory leak when swiped (#5601)

Yogev Ben David 5 vuotta sitten
vanhempi
commit
2b4d897f19
2 muutettua tiedostoa jossa 9 lisäystä ja 1 poistoa
  1. 1
    1
      lib/ios/RNNModalManager.h
  2. 8
    0
      lib/ios/RNNModalManager.m

+ 1
- 1
lib/ios/RNNModalManager.h Näytä tiedosto

@@ -12,7 +12,7 @@ typedef void (^RNNTransitionRejectionBlock)(NSString *code, NSString *message, N
12 12
 
13 13
 @end
14 14
 
15
-@interface RNNModalManager : NSObject
15
+@interface RNNModalManager : NSObject <UIAdaptivePresentationControllerDelegate>
16 16
 
17 17
 @property (nonatomic, weak) id<RNNModalManagerDelegate> delegate;
18 18
 

+ 8
- 0
lib/ios/RNNModalManager.m Näytä tiedosto

@@ -29,6 +29,10 @@
29 29
 	UIViewController* topVC = [self topPresentedVC];
30 30
 	topVC.definesPresentationContext = YES;
31 31
 	
32
+	if (viewController.presentationController) {
33
+		viewController.presentationController.delegate = self;
34
+	}
35
+	
32 36
 	RNNAnimationsTransitionDelegate* tr = [[RNNAnimationsTransitionDelegate alloc] initWithScreenTransition:viewController.resolveOptions.animations.showModal isDismiss:NO];
33 37
 	if (hasCustomAnimation) {
34 38
 		viewController.transitioningDelegate = tr;
@@ -105,6 +109,10 @@
105 109
 	[_delegate dismissedModal:viewController];
106 110
 }
107 111
 
112
+- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController {
113
+	[_presentedModals removeObject:presentationController.presentedViewController];
114
+}
115
+
108 116
 -(UIViewController*)topPresentedVC {
109 117
 	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
110 118
 	while(root.presentedViewController) {