Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Status bar entire view moves down - iOS 11

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 enter image description here

like image 711
Theo Strauss Avatar asked Jun 27 '17 10:06

Theo Strauss


3 Answers

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
}
like image 196
Pavel Vavilov Avatar answered Nov 09 '22 02:11

Pavel Vavilov


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.

like image 21
Arthur Alvarez Avatar answered Nov 09 '22 01:11

Arthur Alvarez


if (@available(iOS 11.0, *)) {
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
like image 8
weikel Avatar answered Nov 09 '22 00:11

weikel