UITableView 的大小在不同的屏幕尺寸上表现得很奇怪

Size of UITableView behaves strange on different screen sizes

我在 Storyboard 中创建了一个 UITableView,前导和尾随 space -20.0 到 superview 以使其横跨整个屏幕。

奇怪的是,当我现在 运行 在 iPhone 6(模拟器)和 viewDidLoad 中打印时:

 print("TableView width: \(tableView.frame.width)")
 print("Screen width: \(UIScreen.mainScreen().bounds.width)") 

我明白了

TableView width: 600.0
Screen width: 375.0

同样在 viewDidAppear 中给我:

TableView width: 383.0
Screen width: 375.0

在 iPhone 6 Plus(也是模拟器)打印件上做完全相同的事情

TableView width: 600.0
Screen width: 414.0

TableView width: 414.0
Screen width: 414.0

分别

为什么 table 视图的宽度不同于 iPhone 6 情况下的屏幕宽度,而不是 6 Plus 情况下的屏幕宽度?

我 运行 遇到这个问题,我认为这是某种错误或不良功能,为了解决这个问题,我以编程方式创建了自定义单元格,并使用屏幕宽度和高度进行了一些计算以放置对象并在不使用任何奇怪的 a$$ 约束的情况下适当调整它们的大小,这对我来说非常有效,但其他人可能有更好的解决方案适合某些人而不适合其他人,请考虑 (以编程方式)方法,我觉得很好,祝你好运。