开发者

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?


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.


If i understand your question, you want to change the height of UITableViewCells, right? Try adding this line in your TableView's delegate:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return *height*;
}

I was having the same problem. If you set the size in IB, you can put more stuff in there, but it will still ask your delegate for the height when loading. If your delegate does not implement this method, it will simply take the default height.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜