I recently upgraded to Xcode 9-beta and iOS 11. When I did and pushed play on my project, all of my views were pushed around 20px down by the status bar, instead of the status bar being directly on top of my view. My partner, who has iOS 10, does not have this issue. I have attached a screenshot for your reference.
Can anyone offer some advice? Any help would be much appreciated. Thanks so much in advance.
Cheers, Theo
Swift answer
You may want to set contentInsetAdjustmentBehavior
of your tableView
or scrollView
object to .never
.
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
or
if #available(iOS 11.0, *) {
scrollView.contentInsetAdjustmentBehavior = .never
}
I was facing the same problem and after HOURS of search, I finally found the problem.
Xcode 9 has a new concept of Safe Areas and by default, the storyboard now adds a safe area at the top of all views.
If you select the root view of your ViewController and select the Size Inspector you'll see a checkbox, as you can see on the image
Uncheck it and this top padding will go away.
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With