升级到 Xcode 11 后,我刚刚收到 Swift 编译器错误
。我在 UIViewController 中使用 UITableView。所以我将 UITableView 委托(delegate)给 UIView。我正在使用 UITableView.automaticDimension 来使用 tableview 单元格的自动高度(自从我使用 Xcode 8 以来,这工作得很好)。并且出现 Xcode 错误建议,指出 'automaticDimension' 已重命名为 'UITableViewAutomaticDimension'
。所以我按照建议将代码更改为 UITableViewAutomaticDimension
。构建后几秒钟,当前代码上会出现新建议,表示“UITableViewAutomaticDimension”已重命名为“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
关于swift - Xcode 11 - UITableViewAutomaticDimension 或 UITableView.automaticDimension 上的 Swift 编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58742647/