Skip to content

Commit

Permalink
Fix/rootview bounds iphone x (#3405)
Browse files Browse the repository at this point in the history
* Fixed issue with rightButtons getting ignored in preference for empty Screen buttons

* Fixes an issue where on an iPhone X when showing the tab bar on pop from
a scrollable view to a non-scrollable view the root view's bounds
would be incorrect
  • Loading branch information
simonmitchell authored and yogevbd committed Jun 25, 2018
1 parent 92b3037 commit 9d4eea8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ios/RCCViewController.m
Expand Up @@ -27,6 +27,7 @@ @interface RCCViewController() <UIGestureRecognizerDelegate, UIViewControllerPre
@property (nonatomic, strong) NSDictionary *originalNavBarImages;
@property (nonatomic, strong) UIImageView *navBarHairlineImageView;
@property (nonatomic, weak) id <UIGestureRecognizerDelegate> originalInteractivePopGestureDelegate;
@property (nonatomic, strong) RCTRootView *rootView;
@end

@implementation RCCViewController
Expand Down Expand Up @@ -164,7 +165,9 @@ - (instancetype)initWithComponent:(NSString *)component passProps:(NSDictionary
}

- (void)commonInit:(RCTRootView*)reactView navigatorStyle:(NSDictionary*)navigatorStyle props:(NSDictionary*)props {
self.view = reactView;

self.rootView = reactView;
[self.view addSubview: reactView];

self.edgesForExtendedLayout = UIRectEdgeNone; // default
self.automaticallyAdjustsScrollViewInsets = NO; // default
Expand Down Expand Up @@ -301,6 +304,12 @@ - (void)viewWillDisappear:(BOOL)animated {
[self setStyleOnDisappear];
}

- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
self.rootView.frame = self.view.bounds;
}

// most styles should be set here since when we pop a view controller that changed them
// we want to reset the style to what we expect (so we need to reset on every willAppear)
- (void)setStyleOnAppear {
Expand Down Expand Up @@ -792,7 +801,7 @@ -(void)addExternalVCIfNecessary:(NSDictionary*)props {
UIViewController *viewController = (UIViewController*)obj;
[self addChildViewController:viewController];
viewController.view.frame = self.view.bounds;
[self.view addSubview:viewController.view];
[self.rootView addSubview:viewController.view];
[viewController didMoveToParentViewController:self];
} else {
NSLog(@"addExternalVCIfNecessary: could not create instance. Make sure that your class is a UIViewController whihc confirms to RCCExternalViewControllerProtocol");
Expand Down

0 comments on commit 9d4eea8

Please sign in to comment.