gpt4 book ai didi

ios - UITableView 分隔符在 iPad 的两边都有边距

转载 作者:可可西里 更新时间:2023-11-01 00:52:16 26 4
gpt4 key购买 nike

我有一个 UITableView,其框架设置为父 View 的框架大小。表格 View 在 iPhone 上显示得很好。然而,在 iPad 上,它的两边都有这么厚的边距。

如果我选择单元格,它表明表格确实跨越了整个宽度。但是,分隔符似乎更小。我试过将 layoutMargins 设置为零,但没有效果。以下是我如何将它添加到我的 View 中:

self.optionsView = UITableView()
self.optionsView.delegate = self
self.optionsView.dataSource = self
self.optionsView.hidden = true
self.optionsView.frame.origin = CGPoint(x: view.frame.size.width + 30, y: 0)
self.optionsView.frame.size = view.frame.size
self.optionsView.layer.shadowColor = Palette.shadowColor.CGColor
self.optionsView.layer.shadowRadius = 10.0
self.optionsView.layer.shadowOpacity = 0.3
self.optionsView.clipsToBounds = false

view.addSubview(optionsView)

知道这里出了什么问题吗?

最佳答案

这里是:

tableView.cellLayoutMarginsFollowReadableWidth = false

来自 Apple 文档:

CellLayoutMarginsFollowReadableWidth:

A Boolean value that indicates whether the cell margins are derived from the width of the readable content guide.

什么是可读内容指南:

A layout guide representing an area with a readable width within the view.

讨论:

This layout guide defines an area that can easily be read without forcing users to move their head to track the lines. The readable content area follows the following rules:

The readable content guide never extends beyond the view’s layout margin guide.

The readable content guide is vertically centered inside the layout margin guide.

The readable content guide’s width is equal to or less than the readable width defined for the current dynamic text size.

Use the readable content guide to lay out a single column of text. If you are laying out multiple columns, you can use the guide’s width to determine the optimal width for your columns.

结论:

Apple 决定您将默认使用他们的动态文本引擎,并且在您的表格 View 中仅使用 1 列。如果您不在这种情况下,您可能应该关闭此属性。如果你想知道可读宽度的值,你可以这样得到它:

tableView.readableContentGuide.layoutFrame.width

关于ios - UITableView 分隔符在 iPad 的两边都有边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33578983/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com