Browse Source

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

Yogev Ben David 5 years ago
parent
commit
2b4d897f19
2 changed files with 9 additions and 1 deletions
  1. 1
    1
      lib/ios/RNNModalManager.h
  2. 8
    0
      lib/ios/RNNModalManager.m

+ 1
- 1
lib/ios/RNNModalManager.h View File

12
 
12
 
13
 @end
13
 @end
14
 
14
 
15
-@interface RNNModalManager : NSObject
15
+@interface RNNModalManager : NSObject <UIAdaptivePresentationControllerDelegate>
16
 
16
 
17
 @property (nonatomic, weak) id<RNNModalManagerDelegate> delegate;
17
 @property (nonatomic, weak) id<RNNModalManagerDelegate> delegate;
18
 
18
 

+ 8
- 0
lib/ios/RNNModalManager.m View File

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