使用IB调整大小构建的自定义UITableViewCell? [英] Custom UITableViewCell built using IB resizing?

查看:130
本文介绍了使用IB调整大小构建的自定义UITableViewCell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确保我的单元格的自动调整大小允许灵活的宽度,但是当旋转设备时,单元格不会调整大小。

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

我还验证了tableview是调整大小,问题直接与单元格有关。

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?

使用IB创建的单元格是否曾经重新调整大小?

Are cells created using IB not resized ever?

推荐答案

如果它是未调整大小的单元格的高度我建议您在轮换后修改 UITableView 委托方法。

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
    }

请确保在轮换发生时调用 [tableView reloadData];

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

这篇关于使用IB调整大小构建的自定义UITableViewCell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆