Xcode Storyboard - 在哪里设置 UITableViewCell 高度

标签 xcode swift uitableview uistoryboard

我正在使用 Xcode 7,我正在尝试在 Storyboard 中设置 UITableViewCell 的高度,以便为不同的设备(例如普通和紧凑 x 常规)设置不同的单元格高度。

我找不到这些设置的位置。这只能通过编程方式实现吗?

最佳答案

点击 Size Inspector 之后点击 Table View

并在此处调整您的单元格行高 -

enter image description here


将下面的代码添加到您的 Controller 类 viewDidLoad

tableView.estimatedRowHeight = 100.0 // Adjust Primary table height
tableView.rowHeight = UITableViewAutomaticDimension //This line adjust cell height according to containts

Swift 4 或更高版本

  • 您需要将 UITableViewAutomaticDimension 更改为 UITableView.automaticDimension

tableView.estimatedRowHeight = 100.0 // Adjust Primary table height
tableView.rowHeight = UITableView.automaticDimension

关于Xcode Storyboard - 在哪里设置 UITableViewCell 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37651967/

相关文章:

xcode - 在没有应用程序的情况下为遗留无代码 kext 创建 Dext?

ios - 将 URLSession.DataTaskPublisher 转换为 Future 发布者

ios - 滚动后重用单元​​格后如何维护 TableView 单元格中的值?

cocoa : Send class data to the user interface (Databinding?)

ios - 可以从共享点 url 运行 WKWebView 吗?

iphone - 尝试读取 Xcode Instruments .trace 文件。 .trace 文件的文件格式是什么?

ios - numberOfRowsInSection/3 - 只返回 15 张图像而不是 16 或 17,因为它们不能被 3 整除

swift - AWS S3 图片上传

ios - 将多个原型(prototype)单元格加载到 UITableView

ios - 表有时加载有时崩溃