I was helped by the following:
YouStoryboard.storyboard > YouViewController > Attributes inspector > Uncheck - Adjust scroll view insets.
http://stackoverflow.com/questions/18880341/why-is-there-extra-padding-at-the-top-of-my-uitableview-with-style-uitableviewst
up vote 288 down vote
|
I was helped by the following: YouStoryboard.storyboard > YouViewController > Attributes inspector > Uncheck - Adjust scroll view insets.
|
|||
show 20 more comments
|
up vote 164 down vote
|
I played around with it a bit more and it seems like this is a side-effect of setting the tableView's Because my tableView has a dynamically appearing
I like this solution better than setting a somewhat arbitrary |
||||||||||||||||||||
show 6 more comments
|
up vote 77 down vote
|
Try changing the
It's a workaround, but it works |
||||||||||||||||||||
add a comment
|
up vote 76 down vote
|
try , you can deal with it! |
||||||||||||||||||||
show 4 more comments
|
up vote 67 down vote
|
For IOS 7 if you are allocing a tableview in a view controller you may look into
your problem seemed similar to mine |
||||||||||||||||||||
show 4 more comments
|
up vote 31 down vote
|
You could detect if your app is running iOS7 or greater and add this two methods in your table view delegate (usually in your UIViewController code)
This maybe is not an elegant solution but works for me |
||||||||||||
add a comment
|
up vote 28 down vote
|
According to this transition guide for iOS7 by Apple, the scroll view’s content insets is automatically adjusted. The default value of automaticallyAdjustsScrollViewInsets is set to YES. The UIViewController which has the UITableView should set this property to NO.
This will do the trick. EDIT 1: Also, one could try -
This also removes the extra padding on the top. |
||||||||||||
add a comment
|
up vote 27 down vote
|
I have found the cause of my original bug and created a sample project showcasing it. I believe there is an iOS7 bug. As of iOS7, if you create a UITableView with the Grouped style, but do not have a delegate set on first layout, then you set a delegate and call reloadData, there will be a 35px space at the top that will never go away. See this project I made showcasing the bug:https://github.com/esilverberg/TableViewDelayedDelegateBug Specifically this file:https://github.com/esilverberg/TableViewDelayedDelegateBug/blob/master/TableViewDelayedDelegateBug/ViewController.m If line 24 is active,
there will be an extra 35 px space at the top. If line 27 is active and 24 is commented out,
no space at the top. It's like the tableView is caching a result somewhere and not redrawing itself after the delegate is set and reloadData is called. |
||||||||||||||||||||
add a comment
|
up vote 21 down vote
|
Another quick comment... even in XCode 6.1, there is a bug with vertical spaces appearing at the top of
Sometimes, the only way to fix this issue is to go into the Storyboard and drag the problem control so it's no longer the first subview on the page.
(My thanks to Oded for pointing me in this direction... I'm posting this comment, just to add a few screenshots, to demonstrate the symptoms and fix.) |
||||||||||||||||||||
show 5 more comments
|
up vote 20 down vote
|
Storyboard: Just uncheck:
Code:
|
||||||||
add a comment
|
up vote 16 down vote
|
While using grouped TableView use this to avoid border cutting in viewWillAppear
|
|||
add a comment
|
up vote 14 down vote
|
In my case this was what helped me. I'm supporting ios6 also.
|
||||||||||||||||||||
show 2 more comments
|
up vote 11 down vote
|
Simply add the following to your viewDidLoad in your VC:
|
||
add a comment
|
up vote 9 down vote
|
Swift: iOS I had tableview on scroll view .. when I was click "Back" on the same screen. Scroll view take more space on top.. to solve this I have used :
A Boolean value that indicates whether the view controller should automatically adjust its scroll view insets. Default value is true, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to false if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy. |
||
add a comment
|
up vote 7 down vote
|
I had the same fix as arielyz. Once I moved the UITableView to be not the first subview of the parent view, it went away. My space was 20 px, not 35. I wasn't able to recreate it in a portrait xib, only a landscape xib. I'll file a radar bug later if I can reproduce it in a simple demo app. |
||||||||||||
add a comment
|
up vote 6 down vote
|
A lot of the previous answers above are too hacky. They would break at anytime in the future if Apple decides to fix this unexpected behavior. Root of the issue:
Solution: Then, the most simple and reliable fix is to ensure that your header height is not 0 when you assign it to your table view. Something like this would work:
Something like this would lead to the issue at some point (typically, after a scroll):
|
|||
add a comment
|
up vote 4 down vote
|
I've been banging my head against this one as well. Pretty sure this is an iOS7 bug. What helped me eventually, is the order of views in the xib. I had one view in which table view was displayed correctly, and another in which the table view had that extra 35px space. The only difference between then (UITableView wise), is that in the bad-displaying view UITableView was the first child, whereas in the view which was displaying correctly, it was the second. That did the trick for me, just changing the order of views. I really prefer not to add extra lines of code for a workaround... |
||||
add a comment
|
up vote 4 down vote
|
I think making UIEdgeInsets -35 0 0 0 is tedious. In my case, I implemented tableView: heightForHeaderInSection: method and it has a potential to return 0. When I changed 0 to 0.1f, the problem just went away. |
||||
add a comment
|
up vote 2 down vote
|
I'm assuming that is just part of the new If that space is being represented by a To search through all subviews (I would run this code when the table has no cells, to make it a little easier to read the output):
|
||||||||||||||||||||
add a comment
|
up vote 2 down vote
|
I have just removed It seems that it there is a strange bug in |
||||
add a comment
|
up vote 1 down vote
|
I noticed there are many answers to this question depending on what you're trying to do, so I'd share mine in case anyone is going for something the same effect:
In my view controller, I have a grouped With the default dimensions of a grouped table view header, the "MORE INFO" header is too far below the "5 days ago" label. I fixed it (already the above image) by overriding the heights for the header and footer of each section.
I learned about overriding the heights from @erurainon's comment in the accepted answer, and I also already tried setting the |
||
add a comment
|
up vote 1 down vote
|
Just pin your tableview (or make it begin) at the absolute top of the view. The additional unwanted space is exactly the height of a navigation bar. |
||
add a comment
|
up vote 1 down vote
|
Doing below (Swift) solves the problem, but this works when you don't need a header.
If you do, you'll have to abandon the very first section and use other for content.
And that's it. Model does not know anything about the change, because we transforms the section number upon accessing the data. |
||
add a comment
|
up vote 0 down vote
|
in iOS 7 you view starts a the of the screen instead of beneath the navBar. its vry simple to set that to the bottom of ur navbar. Check THIS answer for the solution, its not the same question but very related to yours. |
||
add a comment
|
up vote 0 down vote
|
use this one i think this help...
|
||
add a comment
|
collectionview
. (When tableview is insidecollectionviewcell
) – Akshit Zaveri Jul 27 '14 at 12:16