Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom UITableViewCell Height

I have made up a few different custom cells in my UITableView in Interface Builder, including each of them having a custom height, larger than the default 44 pixels high.

I then load them up like so:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    static NSString *CellIdentifier;

    for (int cell = 0; cell <= [tableCellsArray count]; cell++) 
    {
        if ([indexPath row] == cell) 
        {
            CellIdentifier = [tableCellsArray objectAtIndex:cell];
        }
    }

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    // Configure the cell...

    return cell;
}

They each have a custom class and in the code above I loop through an array which basically holds the associated cell identifiers. However upon running the app, all the cells return the default 44 pixel height.

Without using the delegate method to return my own cell height, is there not something I have missed which might cause this?

Thanks.

like image 396
Josh Kahane Avatar asked Aug 21 '26 13:08

Josh Kahane


1 Answers

You can change the height of all of your cells in the definition of the tableView, but to set them individualy you have to use the delegate method. It's confusing that you can set it in IB but it is for display purposes only and not used at runtime.

like image 195
lnafziger Avatar answered Aug 23 '26 02:08

lnafziger