ios - 无法更改 UITableViewCell contentView 高度

标签 ios objective-c xcode uitableview ios7

我有一个自定义的 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/

相关文章:

ios - iPhone 相机,如何避免预览 View 上的相机叠加;如何知道何时进入预览 View ?

ios - 在任何 iOS 设备上复制 CVPixelBuffer

ios - 火力基地。 swift :Retrieve a message after 5 hours of the post

c# - 苹果商店设备兼容性

objective-c - 如何以编程方式设置 UIButton 的 Highlight Tint 颜色?

ios - 在不使用属性的情况下,我们如何在 iOS 中访问另一个类中的变量?

ios - MapBox 水域/陆地检测

ios - 添加基于 iOS 5 的框架

ios - 如何将按钮标签存储在变量中?

iphone - iPhone 5 View 布局协助