I have a UITableView in the grouped style, and only one section. However there is some blank space above and below the table view that is shown when the user scrolls too far. How can I remove this blank space?
相关问题
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
- UITableViewCell layout not updating until cell is
- Showing a checkmark accessory view move the table
- Setting the inputAccessoryView of a UITextField to
相关文章
- UITableView dragging distance with UIRefreshContro
- Popover segue to static cell UITableView causes co
- How do you detect key up / key down events from a
- TransitionFromView removes previous view
- ios7 new pan gesture to go back in navigation stac
- Navigation bar disappears when typing in UISearchC
- Inserting row and deleting row simultaneously. UIT
- Swift Change the tableviewcell border color accord
you can also use this code for removing space between first cell of uitableview..
You can do this by altering the
contentInset
property that the table view inherits fromUIScrollView
.This will make the top and bottom touch the edge.
Add this code:
Uncheck Extend Edges Under Top bar.
UIView can be inserted at the top and bottom of the table(drag and drop). Set their properties as transparent and height of 1 px. This is to remove the extra padding in front of the cells.
This answer comes quite late, but I hope it helps someone.
The space is there because of the
UITableView
'stableHeaderView
property. When the thetableHeaderView
property isnil
Apple defaults a view. So the way around this is to create an empty view with a height greater than0
. Setting this overrides the default view thereby removing the unwanted space.This can be done in a Storyboard by dragging a view to the top of a
tableView
and then setting the height of the view to a value of1
or greater.Or it can be done programmatically with the following code:
Objective-C:
Swift:
Comments
As others have noted you can use this same solution for footers.
Sources and Acknowledgements
See the Documentation for more details on the
tableHeaderView
property.Thanks to @liushuaikobe for verifying using the least positive normal number works.
My original answer: https://stackoverflow.com/a/22185534/2789144