0

if you have a UITableView filled with for example 3 rows. like this,

------
------
------

how can i make this?

------

------

------

how can i change the distance between rows in a UITableView.

---- =  a  full row 
Emre Akman
  • 1,212
  • 3
  • 19
  • 25

3 Answers3

3
- (CGFloat)tableView:(UITableView *)atableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {return 20;}

Implement this function in your m.-File. The value which is returned by this function consist of the height of the rows (px).

Malte Onken
  • 769
  • 1
  • 9
  • 20
  • No.. heightForRowAtIndexPath makes a row larger with his Height.. i dont mean that. i mean the distance between 2 rows not the height of the row it self – Emre Akman Aug 17 '11 at 15:00
  • ok, but then your example sketch is not so clear. there is a default border between two rows and i guess you cannot change this attribute. i never saw this. but you could create an empty ghost row, if i understand you right? – Malte Onken Aug 17 '11 at 15:03
  • 1
    Yes sorry my bad it wasnt that clear, hmmmm ill check how the outcome will be with a ghost row and changing the attributes of the border – Emre Akman Aug 17 '11 at 15:05
  • 2
    I am not sure I understand what you are trying to achieve here. If you simply want extra space between your rows, you can take off the border of the cell and create a custom cell with extra white space and/or extra lines. – Magic Bullet Dave Aug 17 '11 at 15:16
2

You can set the rowHeight property of the UITableView.

Magic Bullet Dave
  • 9,006
  • 10
  • 51
  • 81
0

Set the row height in your UITableView - make sure it's longer than the height of your cell.

That extra row height will render as height padding.

  • That seems like the best solution to me - I've used UITableView pretty extensively and as far as I know there isn't any in-built support for 'padding between cells'. If you really wanted you could probably do some subclassing / overriding to achieve it yourself but just setting the row height and keeping a certain amount on the top and bottom 'empty' will achieve the desired effect – James Gupta Jul 16 '13 at 18:37