Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView space between row and sections

I want to make a UITableView as close to the iOS settings view as possible:

enter image description here

How do i create the space between different sections? What's the best way?

like image 982
Lord Vermillion Avatar asked Sep 08 '15 11:09

Lord Vermillion


People also ask

How do you add a space between UITableView cells?

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.

What is Section in UITableView?

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.

How do I change cell height in Swift?

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.


4 Answers

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:

enter image description here

like image 152
Miknash Avatar answered Oct 20 '22 01:10

Miknash


Change Style of UITableView to "Grouped"

like image 35
varsha desai Avatar answered Oct 20 '22 03:10

varsha desai


try these..

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
  return 30; //according to your need..
}

i hope it helps..

like image 44
krushnsinh Avatar answered Oct 20 '22 01:10

krushnsinh


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.

like image 41
Arben Pnishi Avatar answered Oct 20 '22 03:10

Arben Pnishi