第一个应用程序,所以每个问题对我来说都是新的 :-) 我想为我的应用程序创建一个包含说明的选项卡。这些说明包含几个要点,所以我想制作一个静态表格,每个单元格中应该是一个包含一些解释文本的 TextView 。然而,此文本的长度是可变的,因为我使用两种语言制作我的应用程序,所以我不能为每一行或 TextView 使用定义的高度。但我不希望用户滚动每个 TextView ...它们应该完全展开,因此用户唯一需要滚动的是表格 View 。
我希望我解释得够清楚了……有什么提示我该怎么做吗?我在界面生成器中尝试了一些东西,但是一切都保持静态......
最佳答案
您可以按照此链接中的说明使用延迟加载 cellHeights 数组 Best practices for drawing dynamic UITableView row height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([cellHeights objectAtIndex:indexPath.row] == nil) {
... calculate height for your textview and store it in the array at the correct index…
}
return [[cellHeights objectAtIndex:indexPath.row] floatValue];
}
或引用此链接以获取另一种方法 How can I do variable height table cells on the iPhone properly?
苹果有很好的 mac 示例 apple example
关于iOS:使表格 View 单元格(或 TextView ?)根据需要增大或缩小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20346928/