iphone - 表格 View 单元格随文本大小展开或收缩

标签 iphone objective-c ios uitableview resizable

我一直在用从数据库中获取的数据填充 UITable View 单元格。不同单元格的数据长度不同。所以我需要根据数据长度扩展或收缩高度。目前,我正在使用带有以下代码的自定义单元格

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *cellID= @"customcell4fan";
    customcell4fan *cell = (customcell4fan *)[tableView dequeueReusableCellWithIdentifier:cellID];

    if(cell==nil)
    {
        NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"customcell4fan" owner:nil options:nil];

        for(id currentObject in nibObjects)
        {
            if([currentObject isKindOfClass: [customcell4fan class]])
            {
                cell = (customcell4fan *)currentObject;
            }

        }
    }

eleme = [xmlElementObjects objectAtIndex:indexPath.section];

NSString *email= [eleme.title stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \n\t"]];
    NSString *postData= [eleme.description stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \n\t"]];
cell.nameLabel.text=email;
    cell.postLabel.text=postData;

  return cell;

}

最佳答案

关于iphone - 表格 View 单元格随文本大小展开或收缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9834423/

相关文章:

iphone - subview 淡入淡出帮助

iphone - 我可以创建带有子单元格的 UITableView 吗?

iphone - 如何调试 if(sqlite3_step(selectstmt) == SQLITE_DONE) 的结果

objective-c - 为声明的属性合成了哪些等效代码?

ios - ComputerNode 不显示 Objective-C

ios - 当应用程序进入后台时,约束会重置 - iOS 13

ios - 为剪辑 UIImage 的 UIBezierPath 设置动画

ios - 如何始终转换到 iOS 中选项卡的初始 View ?

ios - 如果未在didFinishLaunchingWithOptions方法中初始化的结构无法工作

iphone - 除了使用双指针之外,还有什么方法可以通过使用@selector 从方法中获取返回值吗?