Skip to content

Commit

Permalink
[ios] release view from controller when popped from stack (#258)
Browse files Browse the repository at this point in the history
This issue is related to #92.

Issue
I got issue when playing video with react-native-video. The video keep playing (still hear sound) when go back.

react-native: 0.61.5
react-native-screens: 2.0.0-alpha.22
Solution
When controller popped, try to assign view to nil to break the cycle.
  • Loading branch information
r0b0t3d authored and osdnk committed Jan 11, 2020
1 parent ca6319d commit 28f5724
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ios/RNSScreenStack.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ @implementation RNSScreenStackView {
NSMutableArray<RNSScreenView *> *_reactSubviews;
NSMutableSet<RNSScreenView *> *_dismissedScreens;
NSMutableArray<UIViewController *> *_presentedModals;
__weak UIViewController* recentPopped;
__weak RNSScreenStackManager *_manager;
}

Expand Down Expand Up @@ -69,6 +70,10 @@ - (void)navigationController:(UINavigationController *)navigationController didS
[_dismissedScreens addObject:[_reactSubviews objectAtIndex:i - 1]];
}
}
if (recentPopped != nil) {
recentPopped.view = nil;
recentPopped = nil;
}
}

- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
Expand All @@ -77,7 +82,8 @@ - (void)navigationController:(UINavigationController *)navigationController didS
if (operation == UINavigationControllerOperationPush) {
screen = (RNSScreenView *) toVC.view;
} else if (operation == UINavigationControllerOperationPop) {
screen = (RNSScreenView *) fromVC.view;
screen = (RNSScreenView *) fromVC.view;
recentPopped = fromVC;
}
if (screen != nil && (screen.stackAnimation == RNSScreenStackAnimationFade || screen.stackAnimation == RNSScreenStackAnimationNone)) {
return [[RNSScreenStackAnimator alloc] initWithOperation:operation];
Expand Down

0 comments on commit 28f5724

Please sign in to comment.