iphone - 如何增加iPhone表格 View 中单元格的高度?

标签 iphone objective-c uitableview row-height

我是 iPhone 开发新手。我正在解析 xml 文件并在表格的每一行中显示标题、日期、 View 和摘要。摘要的内容很大,因此单元格中只显示前 3 个单词。我怎样才能相对于内容的长度增加行的高度。所有内容都应该正确地适合单元格并且应该显示完整的内容。请帮助我。谢谢。

最佳答案

您可以在 tableView.delegate/datasource 中执行此操作:

- (CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   switch (indexPath.row){
       case 0:
         if(indexPath.section==0)
            return 123.0; // first row is 123pt high
       default:
         return 40.0; // all other rows are 40pt high 
   }
}

但这确实会降低滚动性能。理想情况下,您应该使用 tableview.rowHeight 将所有行的行高设置为相同。

关于iphone - 如何增加iPhone表格 View 中单元格的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2252628/

相关文章:

iphone - 从 cellForRowAtIndexPath 获取单元格编号

ios - Branch.io 在web端生成链接,然后在app中获取

iphone - 加载到 UIScrollview 中的图像尺寸错误

iphone - 适用于 iOS SDK 的 Magento oauth api

ios - 将自定义 UIView 添加到 UITableViewController

objective-c - 从 Swift 类获取值到 Objective-C 类

javascript - 动态替换ios项目中的.h和.m文件(bundle路径)

iphone - 尝试同时录制和播放音频,但很安静

ios - 按距离对 UITableView 进行排序/排序

iphone - UITableViewCell 清晰背景 - 分组 UITableView