开发者

iPhone App Dev - changing number of rows in TableView

开发者 https://www.devze.com 2023-03-20 06:26 出处:网络
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开发者_如何学JAVA up the

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开发者_如何学JAVA up the entire height of the screen... How is this possible?


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;
}


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];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消