【问题标题】:How to set tableview cell separator to 100% width in Swift 3.0?如何在 Swift 3.0 中将 tableview 单元格分隔符设置为 100% 宽度?
【发布时间】:2017-08-21 21:04:59
【问题描述】:

我正在开发我的第一个应用程序,并且一切正常,除了我在 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
}

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

任何想法都将不胜感激,

谢谢

【问题讨论】:

    标签: ios xcode uitableview ipad swift3


    【解决方案1】:

    我相信这是由Readable Content Guide 引起的。你可以通过设置tableView.cellLayoutMarginsFollowReadableWidth = false来禁用它

    【讨论】:

    • 谢谢,就是这样。感谢您的帮助。
    • 很高兴能为您提供帮助 :D 您能接受我的回答吗?
    • 默认为假,所以这个答案没有帮助
    • @amitooshacham 从那时起,Apple 在 iOS 10 或 11 中添加了一个关于分隔符边距的新 API(我不确定 iOS 版本)。所以你可能也需要看看那个 API
    猜你喜欢
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    • 2010-10-21
    • 1970-01-01
    • 2017-01-27
    相关资源
    最近更新 更多