-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SafeAreaView doesn't work on iOS 10 and below #17638
Comments
I noticed the same issue which appears to be dependent on the iOS version. SafeAreaView does not seem to provide any space for the StatusBar on iOS 10 (I tested this on iOS 10.3), but works perfectly on iOS 11. My fix was to use this package instead: react-native-safe-area-view |
It is because SafeAreaView in RN (at least in 0.53) is simple converts UIView.safeAreaInsets property to Indeed iOS provides another (now deprecated and bad designed imho) way to get "safe area" on pre iPhone X devices: UIViewController.topLayoutGide. This method has many problems to be integrated into RN properly mainly because it operated on View Controllers level, but RN operates on UIView level, e.g. standalone RN application has one naked UIViewController that contains only default logic... I think backward compatibility for PS. mentioned |
This comment has been minimized.
This comment has been minimized.
Still not working with React Native 0.53. For me it works with react-native-safe-area-view. |
Looks like @vovkasm clearly describe why this happens on iOS 10: #17638 (comment). Closing as that seems to provide a reasonable workaround. |
@grabbou is there a constant exposed for statusbar height on iOS? if it is, then we could use it on older versions of iOS for |
Status bar height is not a constant on iOS. It can change dynamically, e.g. while incoming call. But ideally |
@vovkasm yeah, but |
Right. And I mention that already in #17638 (comment) |
Just create PR #18534, can anyone test it in real application? |
Let's carry on the review process in there. I'll try to give it a shot since I am working on the library that uses it heavily right now. Thanks for submitting pull request :) |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
All right bots... Issue is still actual. But no one is concerned, so we have our own fork of RN with proper fix. |
Tested safeareaview on RN 0.55, it does not work on or below iOS 10. Application goes behind the status bar. |
While this is being taken care of, could SafeAreaView also be made to avoid content from going under the statusbar on android? I don't like having to hard-code margin height, it seems sketchy and destined to result in future bugs. Also, SafeAreaView should be able to avoid statusbar on ios and android w/o separate implementations. |
Same issue. The solution that I found is to use this library from the time being, same implementation: |
Summary: Currently `SafeAreaView` works only on iOS 11, because implemented in terms of native safeArea API, that not exists in older iOS versions. But this make it hard to use the component in real applications, because content will be under top bars on older versions of iOS and no reliable way to workaround this in js. More motivation in facebook#17638 This changeset emulate safe area in terms of `UIViewController` layout guides API if safeArea not available. Fixes facebook#17638, facebook#18255 I run RNTester with these simulators: iPhone6 (9.3), iPhone6 (10.0), iPhone6 (11.2), iPhoneX (11.2) - Start RNTester application - Look on top header, it should not overlap status bar - Go to the `<SafeAreaView>` example, open modal - Modal area should not overlap status bar <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_10_20662C5B.png" width="40%"> <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_11_20662CC8.png" width="40%"> <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_10_pr_20662DE6.png" width="40%"> <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_11_pr_20662DA8.png" width="40%"> [IOS] [BUGFIX] [SafeAreaView] - Make SafeAreaView to work on iOS < 11 Pull Request resolved: facebook#18534 Reviewed By: PeteTheHeat, shergin Differential Revision: D9166052 Pulled By: hramos fbshipit-source-id: c086e1ae4af13110a7453b770ca75b6e0d5321ea
Quick workaround: const WorkaroundView = props => {
if (Platform.OS === 'ios' && Platform.Version < 11)
return <View {...props} style={[props.style, { paddingTop: 15 }]} /> // Add padding to avoid rendering behind StatusBar
else return <SafeAreaView {...props} />
} Then use |
Is this a bug report?
don't know
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.4.0
Xcode: 9.2
react-native: 0.48.1 => 0.48.1
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
Target Platform: iOS 10 and greater
Steps to Reproduce
in my index.ios.js
My React Native app on iOS 10 starts from under the status bar but in iOS 11 the app starts from below the status bar. I want to start the app from 0x 0y off screen for all versions of iOS and the nav bar under the status bar. In Android there is a function called setTranslucent() but on iOS I didn't find a function which supports this. In my index.ios.js
@redmar @mojodna @aroth
The text was updated successfully, but these errors were encountered: