iOS 13 个 UITableViewCell | Child 视图被剪掉
iOS 13 UITableViewCell | Child view gets clipped out
所以我有一个 UITableView
,其中包含一个 UITableViewCell
并且 tableView.header
设置为视差 Header。 UITableViewCell
具有某些 UIView
s,它们被设置为来自 Top 的负约束并且在 iOS-12 上完美显示,而在 iOS-13 在视差 Header 上显示的 UIView
被剪裁。我已经尝试了所有可能的解决方案,但不幸的是它仍然显示相同。我的应用程序选择退出 SwiftUI,但仍然 运行 旧代码。我什至尝试更改 child UIView
的 zIndex
但还是一样。以下是一些快照和一些代码:
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
self.PriceView.layer.zPosition = 1
self.PriceView.bringSubviewToFront(self.contentView)
self.PriceView.setNeedsDisplay()
}
此代码适用于 iOS-12 但不适用于 iOS-13.
更新:
Apple 的 changelog/documentation for iOS-13 建议:
The UITableViewCell class’s contentView property is always laid out
edge-to-edge with adjacent accessories, both on the leading and the
trailing side. This streamlines the layout code so developers who want
the correct default offset no longer have to align their content with
the content view border or the layout margin depending on whether
there is an accessory on the trailing side or not. You should now
always lay out their code on the layout margins of the cell’s content
view to get the default system insets. These insets will be adjusted
automatically based on the accessories visible in the cell to match
the system’s default spacing. (48214114)
这对我来说有点不清楚,如果有人可以帮助我。
这是关于它在 iOS-12 中的显示方式的快照,这是必需的,以及它在 [=70 中的显示方式=]-13分别为:
这里观察 iOS-13:
这也是我的UITableViewCell
的PriceView
的约束布局:
我需要在两个操作系统上保持一致。非常感谢您的帮助!
哇哦!我终于弄明白了。因此,在默认情况下,它在 iOS-12 上工作,但在 iOS-13 和 UITableViewCell
之后如问题中所述进行更改,它停止工作。这是我所做的:
- 首先,在 Size Inspector 中,
UITableViewCell
的 ContentView
设置为 Safe Area Layout Guide
,我将其关闭并打开 Safe Area Relative Margins
,类似地,我对 child 和 PriceView 做了同样的事情。
- 其次,在 Attributes Inspector 中,
ContentView
和 UITableViewCell
都有它们的 Autoresize Subviews
属性 开着,我干脆关了
瞧!有用。希望任何可能遇到这些 UITableViewCell
问题的人,请注意现在它都是相对的
实际上,对我有用的是从内容视图的属性检查器中取消选中 "clip to bounds"
所以我有一个 UITableView
,其中包含一个 UITableViewCell
并且 tableView.header
设置为视差 Header。 UITableViewCell
具有某些 UIView
s,它们被设置为来自 Top 的负约束并且在 iOS-12 上完美显示,而在 iOS-13 在视差 Header 上显示的 UIView
被剪裁。我已经尝试了所有可能的解决方案,但不幸的是它仍然显示相同。我的应用程序选择退出 SwiftUI,但仍然 运行 旧代码。我什至尝试更改 child UIView
的 zIndex
但还是一样。以下是一些快照和一些代码:
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
self.PriceView.layer.zPosition = 1
self.PriceView.bringSubviewToFront(self.contentView)
self.PriceView.setNeedsDisplay()
}
此代码适用于 iOS-12 但不适用于 iOS-13.
更新:
Apple 的 changelog/documentation for iOS-13 建议:
The UITableViewCell class’s contentView property is always laid out edge-to-edge with adjacent accessories, both on the leading and the trailing side. This streamlines the layout code so developers who want the correct default offset no longer have to align their content with the content view border or the layout margin depending on whether there is an accessory on the trailing side or not. You should now always lay out their code on the layout margins of the cell’s content view to get the default system insets. These insets will be adjusted automatically based on the accessories visible in the cell to match the system’s default spacing. (48214114)
这对我来说有点不清楚,如果有人可以帮助我。
这是关于它在 iOS-12 中的显示方式的快照,这是必需的,以及它在 [=70 中的显示方式=]-13分别为:
这里观察 iOS-13:
这也是我的UITableViewCell
的PriceView
的约束布局:
我需要在两个操作系统上保持一致。非常感谢您的帮助!
哇哦!我终于弄明白了。因此,在默认情况下,它在 iOS-12 上工作,但在 iOS-13 和 UITableViewCell
之后如问题中所述进行更改,它停止工作。这是我所做的:
- 首先,在 Size Inspector 中,
UITableViewCell
的ContentView
设置为Safe Area Layout Guide
,我将其关闭并打开Safe Area Relative Margins
,类似地,我对 child 和 PriceView 做了同样的事情。 - 其次,在 Attributes Inspector 中,
ContentView
和UITableViewCell
都有它们的Autoresize Subviews
属性 开着,我干脆关了
瞧!有用。希望任何可能遇到这些 UITableViewCell
问题的人,请注意现在它都是相对的
实际上,对我有用的是从内容视图的属性检查器中取消选中 "clip to bounds"