I want to make a UITableView as close to the iOS settings view as possible:
How do i create the space between different sections? What's the best way?
The way I achieve adding spacing between cells is to make numberOfSections = "Your array count" and make each section contains only one row. And then define headerView and its height. This works great.
UITableView with sections allows us to separate the list into different categories, so the list looks more organized and readable. We can customize sections as per our need, but in this tutorial, we are covering the basic UITableview with sections. Here's is the video if you prefer video over text.
To change the height of tableView cell in ios dynamically, i.e resizing the cell according to the content available, we'll need to make use of automatic dimension property.
You just select grouped style in the Interface Builder and it will separate the table per section, similar as is in the screenshot.
Here is an attachment:
Change Style of UITableView to "Grouped"
try these..
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 30; //according to your need..
}
i hope it helps..
First of all the iOS Settings doesn't use the ViewForSection otherwise the Section view would be placed in the top tableView.
You can return an empty containerView cell for that specific indexPath and stop didSelect in it, but remember to include the empty cells to the array you are using for other cells.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With