You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

单ViewController中两个UICollectionView报错求助

Fixing "could not dequeue a view of kind: UICollectionElementKindCell with identifier InProgressCVC"

Hey there, let's break down why you're hitting this error and how to fix it straight away. That error message is telling you your app can't locate a collection view cell with the identifier InProgressCVC — this almost always happens because you haven't properly registered the cell or linked it up in your storyboard.

Option 1: If you're using a prototype cell in Storyboard

If you built InProgressCVC as a prototype cell directly in your Storyboard, follow these steps to fix the issue:

  • Open your Storyboard and navigate to the FeedVC scene.
  • Locate the collectionViewProgress UICollectionView.
  • Select its prototype cell, then open the Attributes Inspector:
    • Make sure the Identifier field is exactly InProgressCVC (capitalization and spelling matter!).
  • Next, open the Identity Inspector for that prototype cell:
    • Confirm the Class is set to InProgressCVC (not the default UICollectionViewCell).
  • Double-check that your collectionViewProgress IBOutlet is correctly connected to the CollectionView in the Storyboard (no broken connection lines).

Option 2: If you're using a separate XIB or code-only cell

If your InProgressCVC lives in a separate XIB file or is written entirely in code, you need to register it explicitly in viewDidLoad:

For a XIB-based cell:

Add this line right after setting the delegate and dataSource for collectionViewProgress:

collectionViewProgress.register(UINib(nibName: "InProgressCVC", bundle: nil), forCellWithReuseIdentifier: "InProgressCVC")

For a code-only cell:

Use this line instead:

collectionViewProgress.register(InProgressCVC.self, forCellWithReuseIdentifier: "InProgressCVC")

Quick double-check

Since your first collection view (collectionView) is working, compare its setup to collectionViewProgress — you almost certainly missed the same registration/linking step for the second one. Also, make sure InProgressCVC properly subclasses UICollectionViewCell (no typos in the class definition!).

内容的提问来源于stack exchange,提问作者Robbie Wais

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:05:24