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:
This will fix it for a UITableViewController (without any magic numbers). The only thing I couldn't get it to fix is if you are on a phone call, in which case the top of the tableView is pushed down too much. If anyone knows how to solve that, please let us know.
For Xcode 7, un-ticking the 'translucent' check mark for the Navigation Bar worked for me.
chappjc's answer works great when working with XIBs.
I found the cleanest solution when creating TableViewControllers programmatically is by wrapping the UITableViewController instance in another UIViewController and setting constraints accordingly.
Here it is:
Cheers, Ben
I ended up using one extra view with desired background, added after TableView and placed under status bar:
It's not very pretty, but it's rather simple solution, if you need work with xib-less views, and both IOS6 and IOS7
If you are doing things programatically and are using a
UITableViewController
without aUINavigationController
your best bet is to do the following inviewDidLoad
:Swift 3
Earlier Swift
The
UITableViewController
will still scroll behind the status bar but won't be under it when scrolled to the top.Please note: This worked for me for the following configuration:
If the above two requirements aren't met your milage may vary.
Original Post
I created my view programmatically and this ended up working for me:
Source (in topLayoutGuide section at bottom of pg.39).