Josh Kahane Josh Kahane - 7 months ago 47
Objective-C Question

Set Height Programmatically for a Single UITableViewCell?

I need to set the height for a single UITableViewCell in my UITableView programmatically. How can I do this?

I need this one cell to be 150 pixels high and all the others can stay at their default 44 pixels in height.


Max Max

There is a delegate function for the UITableViewCell height.

Here you specify the indexPath of that particular cell and return your height for it

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(indexPath.section == yourSection && indexPath.row == yourRow) {
        return 150.0;
    // "Else"
    return someDefaultHeight;