Xcode 无法将标识符为的UICollectionElementKindCell类型的视图出列

Xcode 无法将标识符为的UICollectionElementKindCell类型的视图出列,xcode,swift2,uicollectionview,identifier,Xcode,Swift2,Uicollectionview,Identifier,我正在创建collectionview。我以编程方式设置CollectionViewController,并创建customCell文件。我在故事板中设计单元。我以前做过,而且效果很好。但出于某种原因,我一直在犯这个错误。我的CustomCell类在情节提要中连接。该标识符与collectionviewcontroller方法中指定的标识符完全相同。我已清理、退出并重新启动xcode。我甚至尝试用另一个我知道有效的单元格界面运行collectionviewcontroller。无论我做什么,我都

我正在创建collectionview。我以编程方式设置CollectionViewController,并创建customCell文件。我在故事板中设计单元。我以前做过,而且效果很好。但出于某种原因,我一直在犯这个错误。我的CustomCell类在情节提要中连接。该标识符与collectionviewcontroller方法中指定的标识符完全相同。我已清理、退出并重新启动xcode。我甚至尝试用另一个我知道有效的单元格界面运行collectionviewcontroller。无论我做什么,我都会遇到这个标识符问题。这里有一些代码

import Foundation

import UIKit

import Alamofire

class CommentsCollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
    override func viewDidLoad() {
        super.viewDidLoad()

        self.collectionView?.backgroundColor = UIColor(white: 0.85, alpha: 1)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 1
    }

    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        let cellIdentifier = "CommentsCollectionViewCell"
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellIdentifier, forIndexPath: indexPath) as! CommentsCollectionViewCell

        return cell
    }

}
这是我的收藏视图单元:

import Foundation
import UIKit
import Cosmos

class CommentsCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var profileImageView: UIImageView!
    @IBOutlet weak var usernameLabel: UILabel!
    @IBOutlet weak var userRatingView: CosmosView!
    @IBOutlet weak var compatibilityLabel: UILabel!
    @IBOutlet weak var commentLabel: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
    }
}

这是我的错误:

2016-07-01 10:55:40.349 ViewerReviewApp[6377:289741]***由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法将具有标识符CommentCell的UICollectionElementKindCell类型的视图出列-必须为标识符注册nib或类,或连接故事板中的原型单元格”

***第一次抛出调用堆栈: ( 0 CoreFoundation 0x000000010e05bd85异常预处理+165 1 libobjc.A.dylib 0x00000001104c7deb objc_异常_抛出+48 2 CoreFoundation 0x000000010e05bbea+[NSException raise:格式:参数:][106 3基金会0x000 000 010EB14D5A- [ NSRealStutsHuffer-HuffLeuluIn方法:对象:文件:文件号:描述:] + 198 4 UIKit 0x000000010f7d4a60-[UICollectionView\u dequeueReusableViewOfKind:带标识符:forIndexPath:viewCategory:+2009 5 UIKit 0x000000010f7d4ebc-[UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:+169 6 ViewerReviewApp 0x000000010d729ee7\u TFC16 ViewerReviewApp25CommentFeedViewController14CollectionViewFTCSO16UICollectionView22CellforItemAtIndexPathCSO11nSIndepath\u CSo20UICollectionViewCell+151 7 ViewerReviewApp 0x000000010d729f9f\u TTOFC16ViewerReviewApp25CommentFeedViewController14CollectionViewFTCSO16UICollectionView22CellforItemAtIndexPathCSO11nSIndepath\U CSo20UICollectionViewCell+79 8 UIKit 0x000000010f7c308f-[UICollectionView\u createPreparedCellForItemAtIndexPath:带布局属性:应用属性:isFocused:+483 9 UIKit 0x000000010f7c6d96-[UICollectionView\u updateVisibleCellsNow:+4988 10 UIKit 0x000000010f7cb575-[UICollectionView布局子视图]+258 11 UIKit 0x000000010f006980-[UIView(CALayerDelegate)布局层的子层:+703 12夸脱核心0x0000000115522c00-[CALayer布局子层]+146 13夸脱核心0x000000011551708e(如果需要)Zn2Ca5层布局交易+366 14夸脱核心0x0000000115516f0c\U ZN2CA58层布局和显示(如果需要)PNS\U 11事务+24 15夸脱核心0x000000011550 B3C9_ZN2CA7Context18提交交易PNS_11交易+277 16夸脱核心0x0000000115539086_Zn2Ca11交易承诺+486 17 UIKit 0x000000010ef7819b在CACommithandler+174之后 18 CoreFoundation 0x000000010df80c37运行循环正在调用一个观察者回调函数 19 CoreFoundation 0x000000010df80ba7\uuu cfrunloopdoobserver+391 20 CoreFoundation 0x000000010df767fb__CFRunLoopRun+1147 21 CoreFoundation 0x000000010df760f8 CFRunLoopRunSpecific+488 22图形服务0x00000001153e5ad2 GSEventRunModal+161 23 UIKit 0x000000010ef4bf09 UIApplicationMain+171 24 viewerReviewApp 0x000000010d738ad2 main+114 25 libdyld.dylib 0x0000000111d1392d开始+1 )


我还能做些什么来让这一切顺利进行吗?

我解决了这个问题。这就是我实例化视图控制器的方式。我必须这样表达:

    let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
    let commentsView = storyBoard.instantiateViewControllerWithIdentifier("seeComments")

    self.presentViewController(commentsView, animated: true, completion: nil)
其中“seeComments”是情节提要中的CollectionViewController