Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom UITableViewCell built using IB resizing?

I have ensured the autosizing mask of my cell allows flexible width, but when the device is rotated the Cells are not resized.

I have also verified the tableview is resized, the problem is directly with the cells.

This is the code I am using to create the cells:

if (cell == nil) {
        // Load the top-level objects from the custom cell XIB.
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MetaTableViewCell" owner:self options:nil];
        // Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
        cell = [topLevelObjects objectAtIndex:0];
    }

Can someone think of what might be wrong?

Are cells created using IB not resized ever?

like image 350
Zebs Avatar asked May 18 '26 00:05

Zebs


1 Answers

If its the height of the cell that is not resized I suggest you to modify the UITableView delegate method after rotation.

-

(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(condition)// has rotation taken place
    // new height
    else
    // old height
    }

Pls make sure that you call [tableView reloadData]; when rotation has taken place.

like image 157
visakh7 Avatar answered May 19 '26 13:05

visakh7



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!