The first screen of my application is a UITableViewController
without a navigation bar, which means that the content flows under the status bar so there's a lot of text collisions. I've adjusted both the properties for Under top bars
and Adjust scroll view insets
which do actually stop it from scrolling under, but at the cost of keeping the top of the table view under. I've attempted to set the UITableView
frame to offset by 20 pixels, but it doesn't appear to take effect and as I currently need the app to be compatible with iOS 6 I can't jump to iOS 7 Storyboards to force autolayout to use the top height guide. Has anyone found a solution that works for both versions?
Things I've tried: setting edgesForExtendedLayout
, changing the settings within Storyboard for Under top bars
and Adjust scroll view
, forcing the frame to a new area.
A picture is worth a thousand words:
Abrahamchez's solution https://developer.apple.com/library/ios/qa/qa1797/_index.html worked for me as follows. I had a single UITableviewcontroller as my initial view. I had tried the offset code and embedding in a navcon but neither solved the statusbar transparency.
Add a Viewcontroller and make it the initial view. This should show you critical Top & Bottom Layout Guides.
Drag the old Tableview into the View in the new controller.
Do all the stuff to retrofit the table into the new controller:
Change your old view controller.h file to inherit/subclass from UIViewController instead of UITableViewController.
Add UITableViewDataSource and UITableViewDelegate to the viewcontroller's .h.
Re-connect anything needed in the storyboard, such as a Searchbar.
The big thing is to get the constraints set up, as in the Apple Q&A. I didn't bother inserting a toolbar. Not certain the exact sequence. But a red icon appeared on the Layout Guides, perhaps when I built. I clicked it and let Xcode install/clean up the constraints.
Then I clicked everywhere until I found the Vertical Space constraint and changed its top value from -20 to 0 and it worked perfectly.
I was facing this issue in ios 11 but layout was correct for ios 8 - 10.3.3 . For my case I set a Vertical Space Constraint to Superview.Top Margin instead of Superview.Top which works for ios 8 - 11.