我正在使用 Xcode 7 并且我正在尝试设置故事板中 UITableViewCell 的高度设置为不同的设备具有不同的单元高度(例如,正常和紧凑 x 常规)。
我找不到这些设置的位置。这只能通过编程来实现吗?
单击“表视图”,然后单击“尺寸检查器”
并在此处调整单元格行高 -
在您的控制器类中添加以下代码viewDidLoad
tableView.estimatedRowHeight = 100.0 // Adjust Primary table height
tableView.rowHeight = UITableViewAutomaticDimension //This line adjust cell height according to containts
Swift 4 或更高版本
- 你需要从
UITableViewAutomaticDimension
to UITableView.automaticDimension
tableView.estimatedRowHeight = 100.0 // Adjust Primary table height
tableView.rowHeight = UITableView.automaticDimension
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)