swift - Xcode 11 - UITableViewAutomaticDimension 或 UITableView.automaticDimension 上的 Swift 编译器错误
问题描述
升级到 Xcode 11 后我刚得到一个Swift Compiler Error
。我在我的 UIViewController 中使用 UITableView。所以我将 UITableView 委托给 UIView。我正在使用 tableview 单元格的自动高度UITableView.automaticDimension
(这个工作很好,因为我使用的是 Xcode 8)。并且 Xcode 错误建议出现说'automaticDimension' has been renamed to 'UITableViewAutomaticDimension'
。所以我按照建议将我的代码更改为UITableViewAutomaticDimension
. 'UITableViewAutomaticDimension' has been renamed to 'UITableView.automaticDimension'
构建后几秒钟,如果我反之亦然,则新建议会出现在当前代码上,依此类推。有没有人和我一样的问题?
解决方案
// Swift 4.2 onwards
table.rowHeight = UITableView.automaticDimension
table.estimatedRowHeight = UITableView.automaticDimension
// Swift 4.1 and below
table.rowHeight = UITableViewAutomaticDimension
table.estimatedRowHeight = UITableViewAutomaticDimension
推荐阅读
- python - 完成 env 处理后是否可以删除每个 Tox virtualenv
- css - Laravel snappy - 如何加载内部/外部 css
- java - 解决迭代的更好方法
- permutation - 在 Netlogo 中重复具有变量列表 lentgh 的列表的排列
- c# - Bot Framework - 为什么 Choice 持有 CardAction,每个角色的作用是什么?
- android - 无法使用 TextEditingController 更改文本字段列表中的值
- excel - 如何获取激活/打开的 OLE 对象的工作簿/工作表的句柄?
- r - 在数据集中创建间隙
- java - 我将如何删除最大元素并相应地移动值
- python - 用另一列的值替换字符串的一部分