【问题标题】:UITableView Nested in UICollectionViewCell with No MarginsUITableView 嵌套在 UICollectionViewCell 中,没有边距
【发布时间】:2018-10-05 14:56:18
【问题描述】:

在我当前的项目中,我使用嵌套在每个 UICollectionViewCell 中的 UITableView。在 UITableView 中,我有许多由边框分隔的自定义 UITableViewCell,如屏幕截图所示。

我希望每个边框从左到右拉伸整个屏幕长度,但正如您在第一张图片中看到的那样,每个边框都在屏幕外边缘附近停止。

在第二个屏幕截图中,我在 UITableView 的整个边缘设置了一个边框,以确认确实是导致此问题的 UITableView 的大小。

在 Storyboard 中,UITableView 的上下左右约束设置为与 UICollectionViewCell 相同。

在 UICollectionViewCell 的属性中我将固定边距全部设置为 0,并且“安全区域相对边距”已被取消选择。

在初始化 UICollectionViewCell 时我也试过:

self.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)

感谢您提供的任何帮助。

First Screenshot

Second Screenshot

【问题讨论】:

    标签: ios iphone swift uitableview uicollectionview


    【解决方案1】:

    我是个白痴...忘记了 contentViews 是一个东西。

    二手:self.contentView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0),一切都很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-27
      • 1970-01-01
      • 2012-11-05
      • 1970-01-01
      • 2015-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多