我在 UICollectionViewController
上有一个 childViewController
。我有所以我的 childViewController 出现在屏幕上。但是当我注册一个单元格 collectionView?.register(MyCustomCell.self, forCellWithReuseIdentifier: CellId)
并使用 numberOfItemsInSection
和 cellForItemAt
时。问题是单元格不会出现,我已经检查了代码,所以它是正确的。可以是 childViewController 的东西吗?
最佳答案
通常不建议将任何 subview 或 viewController 添加到 UICollectionViewController 或 UITableViewController,因为您会看到意想不到的结果,因为它们都继承自 scrollview 并使添加的内容能够滚动或散布在任何地方,如果你有更好地创建一个带有 collectionView 和 childViewController
的自定义 viewController关于ios - 在 childViewController 中添加自定义单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47983843/