开发者

Changing in Code Specific Row Heights in Objective-C

I have a UITableView that uses prototype cells to recreate a table. I have the first row with height 30 and the rest default 44. I would like to change only first row's height but have failed to do so. I tried cellForRowAtIndexPath but I learned here that it's heightForRowAtIndexPath: I'm interested in. However, all the Index开发者_如何学运维Path's that get sent to it are [0,0]. Can anyone help?


Have you tried this?

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == 0) { //first row
        return 30;
    }
    else {
        return 44;
    }

}


Do this for resizing the cells in your table views delegate.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
        return 30.0;
    return 44.0;
}

If this doesn't work: give us your code

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜