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:
I have done this for Retina/Non-Retina display as
The following solution works well enough in code without using magic constants, and accounts for the user changing the size class, e.g. through rotations or side-by-side apps on ipads:
Here is a Swift 2.3. (Xcode 8.0) solution. I have created a subclass of UITableView.
The content Inset should always be Zero (by default). I am setting it Zero manually. You can also add a check method which makes the check and if it is anything other than what you want it to be just get the correct rect. The change will reflect only when the tableview is drawn (which does not happen often).
Don't forget to update the TableView in your IB (in the TableViewController or just TableView inside your ViewController).
see all solutions: my project is just use xib, so, the solution with storyboard not worked for me. self.edgesForExtendedLayout = UIRectEdgeNone; just works for controller if navigationbar is visible. but if your view is just have status bar, that will not work. so i combine two conditons.
help this works.
I got it work by setting size to freeform
For those like me who would rather not embed their
UITableViewController
in aUIViewController
try this:A custom
UITableViewController
subclass can append a mask view to the tableView's superview. Add the mask on viewDidAppear, and remove the mask on viewWillDisappear.