我有一个自定义的 uitableviewcell
。
我想根据一些 if 条件改变它的高度。 我怎样才能做到这一点?
我尝试在 cellForRowAtIndexPath
中执行此操作 -
if (cell.newsFeedImage.image == NULL)
{
NSLog(@"NULL");
cell.uDisplayImage.frame = CGRectMake(20, 20, 20, 20);
}
日志消息出现,但框架永远不会改变。
请帮忙。
最佳答案
尝试在 heightForRowAtIndexPath 中执行此操作
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
if (cell.newsFeedImage.image == nil) {
cell.uDisplayImage.frame = CGRectMake(20, 20, 20, 20);
}
else return 40;
}
关于ios - 无法更改 UITableViewCell contentView 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26098168/