How to set tableview cell separator to 100% width

2019-09-19 02:40发布

问题:

I'm developing my first app, and have got everything working except I have discovered a display issue on iPad, where the separator of a cell is limited in width (see screenshot)

Screen shot on iPad

I've tried everything that I can find on how to set the margins to 0, etc, including:

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
}

I'm not using storyboard and I am doing it programmatically,

Any ideas would be appreciated,

Thanks

回答1:

I believe it's caused by Readable Content Guide. You can disable it by setting tableView.cellLayoutMarginsFollowReadableWidth = false