开发者

Changing in Code Specific Row Heights in Objective-C

开发者 https://www.devze.com 2023-03-17 02:44 出处:网络
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 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

精彩评论

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