From 2546c95ac8eeca5a0056d34188a10f75a4b21a44 Mon Sep 17 00:00:00 2001 From: "Y.Shing" Date: Mon, 30 Oct 2017 23:06:11 -0700 Subject: [PATCH] Fix iOS 11 WebView extra white space on top due to contentInsetAdjustmentBehavior Summary: Same IOS 11 issue as https://github.com/facebook/react-native/pull/15023 Fixes the annoying 20px content insert on top. Fix the behaviour of WebView when building the iOS project with Xcode 9 due to the `contentInsetAdjustmentBehavior`. ![expected](https://user-images.githubusercontent.com/5630513/32207551-b7789668-bdca-11e7-840a-f325b2767d08.jpg) ![iphone_x_after](https://user-images.githubusercontent.com/5630513/32207557-beb8fd6e-bdca-11e7-87d0-18d533f20125.jpg) ![issue_normal_iphone_ios11](https://user-images.githubusercontent.com/5630513/32207572-d773be5c-bdca-11e7-8e28-8f0783eef1cd.jpg) ![iphone_x_before](https://user-images.githubusercontent.com/5630513/32207581-e3e93234-bdca-11e7-847d-f801bbf05d55.jpg) [IOS] [BUGFIX] [WebView] - Fix extra white space added to webView due to iOS 11 contentInsetAdjustmentBehavior Closes https://github.com/facebook/react-native/pull/16519 Differential Revision: D6195670 Pulled By: shergin fbshipit-source-id: 08d4d4dc700059bb7707e038dc4f592af0275896 --- React/Views/RCTWebView.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/React/Views/RCTWebView.m b/React/Views/RCTWebView.m index 62823e27813193..596f87e9680330 100644 --- a/React/Views/RCTWebView.m +++ b/React/Views/RCTWebView.m @@ -52,6 +52,11 @@ - (instancetype)initWithFrame:(CGRect)frame _contentInset = UIEdgeInsetsZero; _webView = [[UIWebView alloc] initWithFrame:self.bounds]; _webView.delegate = self; +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */ + if ([_webView.scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) { + _webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } +#endif [self addSubview:_webView]; } return self;