简体   繁体   English

章节索引标题涵盖 UITableViewCell 视图

[英]Section Index Titles Cover UITableViewCell View

I am trying to add a stack view to my UITableViewCell programmatically.我正在尝试以编程方式向我的 UITableViewCell 添加堆栈视图。

The section index titles obstruct the view as such.部分索引标题阻碍了视图。

Here is the code I am using to embed the stack view in the UITableViewCell.这是我用来在 UITableViewCell 中嵌入堆栈视图的代码。

self.addSubview(mainStack)
mainStack.topAnchor.constraint(equalTo: self.safeAreaLayoutGuide.topAnchor, constant: self.TOP_PADDING).isActive = true
mainStack.bottomAnchor.constraint(equalTo: self.safeAreaLayoutGuide.bottomAnchor, constant: -self.BOTTOM_PADDING).isActive = true
mainStack.leadingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.leadingAnchor, constant: self.SIDE_PADDING).isActive = true
mainStack.trailingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.trailingAnchor, constant: 0).isActive = true

How can I fix the view obstruction without relying on a fixed constant (ie some fixed padding)?如何在不依赖固定常量(即某些固定填充)的情况下修复视图障碍?

Change改变

mainStack.trailingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.trailingAnchor, constant: 0).isActive = true

To

mainStack.trailingAnchor.constraint(equalTo: self.contentView.safeAreaLayoutGuide.trailingAnchor, constant: 0).isActive = true

Result:结果:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM