swift - Xcode 11 - UITableViewAutomaticDimension 或 UITableView.automaticDimension 上的 Swift 编译器错误

标签 swift xcode uitableview xcode11

升级到 Xcode 11 后,我刚刚收到 Swift 编译器错误。我在 UIViewController 中使用 UITableView。所以我将 UITableView 委托(delegate)给 UIView。我正在使用 UITableView.automaticDimension 来使用 tableview 单元格的自动高度(自从我使用 Xcode 8 以来,这工作得很好)。并且出现 Xcode 错误建议,指出 'automaticDimension' 已重命名为 'UITableViewAutomaticDimension' 。所以我按照建议将代码更改为 UITableViewAutomaticDimension。构建后几秒钟,当前代码上会出现新建议,表示“UITableViewAutomaticDimension”已重命名为“UITableView.automaticDimension”,依此类推(如果我更改为反之亦然)。有人有和我一样的问题吗? Xcode Screenshot

最佳答案

// 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/

相关文章:

ios - SwiftUI DisclosureGroup 分别展开每个部分

ios - 在当前 vc 之上呈现 vc 后,第二次出现白屏。第一次没收到

ios - 强制类文件包含方法而不添加协议(protocol)的Objective-C方式或编译器指令?

ios - 如何区分原型(prototype) TableView 单元格?

ios - Swift 中的自定义 UITableViewCell 委托(delegate)模式

ios - iPhone 4、5、5s 和 6+ 模拟器错位节点

ios - 获取 UIView 的大小以编程方式添加 subview (计算出的 X、Y、宽度和高度)

ios - 许多设备的按钮图像命名(视网膜和非视网膜)

ios - 如何检查 TableView 单元格字幕是否彼此相等 iOS

iphone - 不会调用 canMoveRowAtIndexPath - 但会调用 canEditRowAtIndexPath