Ver código fonte

Fix/rootview bounds iphone x (#3405)

* 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
Simon Mitchell 6 anos atrás
pai
commit
9d4eea835a
1 arquivos alterados com 11 adições e 2 exclusões
  1. 11
    2
      ios/RCCViewController.m

+ 11
- 2
ios/RCCViewController.m Ver arquivo

@@ -27,6 +27,7 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
27 27
 @property (nonatomic, strong) NSDictionary *originalNavBarImages;
28 28
 @property (nonatomic, strong) UIImageView *navBarHairlineImageView;
29 29
 @property (nonatomic, weak) id <UIGestureRecognizerDelegate> originalInteractivePopGestureDelegate;
30
+@property (nonatomic, strong) RCTRootView *rootView;
30 31
 @end
31 32
 
32 33
 @implementation RCCViewController
@@ -164,7 +165,9 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
164 165
 }
165 166
 
166 167
 - (void)commonInit:(RCTRootView*)reactView navigatorStyle:(NSDictionary*)navigatorStyle props:(NSDictionary*)props {
167
-    self.view = reactView;
168
+    
169
+    self.rootView = reactView;
170
+    [self.view addSubview: reactView];
168 171
     
169 172
     self.edgesForExtendedLayout = UIRectEdgeNone; // default
170 173
     self.automaticallyAdjustsScrollViewInsets = NO; // default
@@ -301,6 +304,12 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
301 304
     [self setStyleOnDisappear];
302 305
 }
303 306
 
307
+- (void)viewDidLayoutSubviews
308
+{
309
+    [super viewDidLayoutSubviews];
310
+    self.rootView.frame = self.view.bounds;
311
+}
312
+
304 313
 // most styles should be set here since when we pop a view controller that changed them
305 314
 // we want to reset the style to what we expect (so we need to reset on every willAppear)
306 315
 - (void)setStyleOnAppear {
@@ -792,7 +801,7 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
792 801
                 UIViewController *viewController = (UIViewController*)obj;
793 802
                 [self addChildViewController:viewController];
794 803
                 viewController.view.frame = self.view.bounds;
795
-                [self.view addSubview:viewController.view];
804
+                [self.rootView addSubview:viewController.view];
796 805
                 [viewController didMoveToParentViewController:self];
797 806
             } else {
798 807
                 NSLog(@"addExternalVCIfNecessary: could not create instance. Make sure that your class is a UIViewController whihc confirms to RCCExternalViewControllerProtocol");