开发者

iPhone App Dev - changing number of rows in TableView

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜