如何在 Swift 3.0 中将 tableview 单元格分隔符设置为 100% 宽度?

How to set tableview cell separator to 100% width in Swift 3.0?

我正在开发我的第一个应用程序,一切正常,除了我在 iPad 上发现了一个显示问题,其中单元格分隔符的宽度有限(参见屏幕截图)

屏幕截图在 iPad

我已经尝试了所有我能找到的关于如何将边距设置为 0 等的方法, 包括:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let myCell = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath) as! MyCell

    myCell.preservesSuperviewLayoutMargins = false
    myCell.separatorInset = UIEdgeInsets.zero
    myCell.layoutMargins = UIEdgeInsets.zero

    return myCell
}

我没有使用情节提要,而是以编程方式进行,

如有任何想法,我们将不胜感激,

谢谢

我认为这是 Readable Content Guide 造成的。您可以通过设置 tableView.cellLayoutMarginsFollowReadableWidth = false

来禁用它