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

蓝咒 提交于 2019-12-12 05:10:00

问题


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



来源:https://stackoverflow.com/questions/43075508/how-to-set-tableview-cell-separator-to-100-width-in-swift-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!