Skip to content

Commit

Permalink
Fix pageSheet modals causing memory leak when swiped (#5601)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd authored and guyca committed Oct 23, 2019
1 parent 507b675 commit 2b4d897
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ios/RNNModalManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typedef void (^RNNTransitionRejectionBlock)(NSString *code, NSString *message, N

@end

@interface RNNModalManager : NSObject
@interface RNNModalManager : NSObject <UIAdaptivePresentationControllerDelegate>

@property (nonatomic, weak) id<RNNModalManagerDelegate> delegate;

Expand Down
8 changes: 8 additions & 0 deletions lib/ios/RNNModalManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ -(void)showModal:(UIViewController<RNNLayoutProtocol> *)viewController animated:
UIViewController* topVC = [self topPresentedVC];
topVC.definesPresentationContext = YES;

if (viewController.presentationController) {
viewController.presentationController.delegate = self;
}

RNNAnimationsTransitionDelegate* tr = [[RNNAnimationsTransitionDelegate alloc] initWithScreenTransition:viewController.resolveOptions.animations.showModal isDismiss:NO];
if (hasCustomAnimation) {
viewController.transitioningDelegate = tr;
Expand Down Expand Up @@ -105,6 +109,10 @@ - (void)dismissedModal:(UIViewController *)viewController {
[_delegate dismissedModal:viewController];
}

- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController {
[_presentedModals removeObject:presentationController.presentedViewController];
}

-(UIViewController*)topPresentedVC {
UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
while(root.presentedViewController) {
Expand Down

0 comments on commit 2b4d897

Please sign in to comment.