0

How do you change the number of rows and the height of the rows within a table view?

I have four items and I want them to occupy equal portions, but grouped together to take up the entire height of the screen... How is this possible?

user559142
  • 12,279
  • 49
  • 116
  • 179

2 Answers2

1

To change the height of the rows

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}

for rows

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
return 4;
}
Aravindhan
  • 15,608
  • 10
  • 56
  • 71
0

You should avoid using magic numbers, something like this might be more useful:

(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
    return self.view.frame.size.height / [yourArray count];
}
Community
  • 1
  • 1
Yunus Nedim Mehel
  • 12,089
  • 4
  • 50
  • 56