我正在使用 Xcode 7,我正在尝试在 Storyboard 中设置 UITableViewCell 的高度,以便为不同的设备(例如普通和紧凑 x 常规)设置不同的单元格高度。
我找不到这些设置的位置。这只能通过编程方式实现吗?
最佳答案
点击 Size Inspector 之后点击 Table View
并在此处调整您的单元格行高 -
将下面的代码添加到您的 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/