ios - 在 childViewController 中添加自定义单元格

标签 ios swift cells childviewcontroller

我在 UICollectionViewController 上有一个 childViewController。我有所以我的 childViewController 出现在屏幕上。但是当我注册一个单元格 collectionView?.register(MyCustomCell.self, forCellWithReuseIdentifier: CellId) 并使用 numberOfItemsInSectioncellForItemAt 时。问题是单元格不会出现,我已经检查了代码,所以它是正确的。可以是 childViewController 的东西吗?

最佳答案

通常不建议将任何 subview 或 viewController 添加到 UICollectionViewControllerUITableViewController,因为您会看到意想不到的结果,因为它们都继承自 scrollview 并使添加的内容能够滚动或散布在任何地方,如果你有更好地创建一个带有 collectionViewchildViewController

的自定义 viewController

关于ios - 在 childViewController 中添加自定义单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47983843/

相关文章:

ios - Swift 2 在更改页面之前检查

swift - TableView 分隔符单元格消失?

java - 使用 Aspose JAva 读取和验证行

ios - 应用程序崩溃并出现错误 : "this class is not key value coding-compliant for the key tableView". 如何修复?

iPhone - 用于计算的正确 UI 控件

ios - 检测用户是否在 iOS 上滚动然后更改 View 颜色

ios - 确定纬度/经度点是否在 Mapview 中的 MKPolygon 中?

ios - 当应用程序关闭时从推送通知打开特定的 ViewController

javascript - jquery 将事件添加到板中的单元格中

ios - Xcode IB : UIButton hidden but have still buttons space