diff --git a/ios/RCCViewController.m b/ios/RCCViewController.m index 5b3bdf75449..2d5609028bc 100755 --- a/ios/RCCViewController.m +++ b/ios/RCCViewController.m @@ -288,10 +288,24 @@ - (void)_traverseAndCall:(UIView*)view }]; } +// fix iOS11 safeArea - https://github.com/facebook/react-native/issues/15681 +// rnn issue - https://github.com/wix/react-native-navigation/issues/1858 +- (void)_traverseAndFixScrollViewSafeArea:(UIView *)view { +#ifdef __IPHONE_11_0 + if ([view isKindOfClass:UIScrollView.class]) { + [((UIScrollView*)view) setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever]; + } + + [view.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [self _traverseAndFixScrollViewSafeArea:obj]; + }]; +#endif + +} + - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - [self sendGlobalScreenEvent:@"didAppear" endTimestampString:[self getTimestampString] shouldReset:YES]; [self sendScreenChangedEvent:@"didAppear"]; @@ -300,6 +314,7 @@ - (void)viewDidAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + [self _traverseAndFixScrollViewSafeArea:self.view]; [self sendGlobalScreenEvent:@"willAppear" endTimestampString:[self getTimestampString] shouldReset:NO]; [self sendScreenChangedEvent:@"willAppear"]; [self setStyleOnAppear];