iPad 中的分隔线未显示全宽

Separator line not showing full width in iPad

分隔线在 iPad 中未显示全宽,但在使用这些线后为 iPhone 设备设置了全宽。

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

我已经通过编程完成了所有这些。这是我的代码

你可以直接在你的 Attribute Inspector 中更改分隔符 Inset --> custom and set left --> 0

并在您的单元格中 class 也更改布局边距

更新

if want to remove the separator inset from all cells, you need to do two things. First, add these two lines of code to your table view controller's viewDidLoad() method:

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.layoutMargins = .zero
    tableView.separatorInset = .zero
}

Now look for you cellForRowAt method and add this:

cell.layoutMargins = .zero 

尝试使用属性检查器设置分隔符插入。

将左值从 15 更改为 0。

尝试在故事板或下图中显示的 xib 的表视图中添加自定义分隔符插入。

这绝对有效。

当我以编程方式创建 UITableView 时,占位符单元格没有扩展到全宽。在浏览了所有可能的方法之后,我发现了这一点。

tableview.cellLayoutMarginsFollowReadableWidth = false

我在设置 contentInset = .zerolayoutMargins = .zero

之后设置这个

希望这对处于相同位置的其他人有所帮助。