2016-07-01 7 views
1
のUICollectionElementKindCell

私は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 
    } 

} 

は、ここに私のCollectionViewCellです:ここでは

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() 
    } 
} 

StoryboardIdentityInspector

StoryboardAttributesInspector

は私のエラーです:

2016年7月1日午前10時55分:40.349 ViewerReviewsApp [6377:289741] *** uncaugのためにアプリケーションを終了していますht例外 'NSInternalInconsistencyException'、理由: '種類のビューをデキューできませんでした:UICollectionElementKindCell(識別子付き)CommentCell - 識別子のnibまたはクラスを登録するか、ストーリーボードのプロトタイプセルを接続する必要があります'

*** first throw呼び出しスタック: ( 0 CoreFoundation 0x000000010e05bd85 exceptionPreprocess + 165 1 libobjc.A。dylib 0x00000001104c7deb objc_exception_throw + 48 2 CoreFoundationのを0x000000010e05bbea + [NSExceptionレイズ:フォーマット:引数:] + 106 3ファンデーション0x000000010eb74d5a - [NSAssertionHandler handleFailureInMethod:目的:ファイル:行番号:説明:] + 198 4のUIKit 0x000000010f7d4a60 - [UICollectionView _dequeueReusableViewOfKind。 withIdentifier:forIndexPath:viewCategory:] + 2009 5のUIKit 0x000000010f7d4ebc - [UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:] + 169 6 ViewerReviewsApp 0x000000010d729ee7 _TFC16ViewerReviewsApp25CommentFeedViewController14collectionViewfTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 151 7 ViewerReviewsApp 0x000000010d729f9f _TToFC16ViewerReviewsApp25CommentFeedViewControl ler14collectionViewfTCSo16UICollectionView22cellForItemAtIndexPathCSo11NSIndexPath_CSo20UICollectionViewCell + 79 8のUIKit 0x000000010f7c308f - [UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:] + 483 9のUIKit 0x000000010f7c6d96 - [UICollectionView _updateVisibleCellsNow:] + 4988 10のUIKit 0x000000010f7cb575 - [UICollectionView layoutSubviews] + 258 11のUIKit 0x000000010f006980 - [ UIViewの(CALayerDelegate)layoutSublayersOfLayer:] + 703 12 QuartzCore 0x0000000115522c00 - [CALayerのlayoutSublayers] + 146 13 QuartzCore 0x000000011551708e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 14 QuartzCore 0x0000000115516f0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11T ransactionE + 24 15 QuartzCore 0x000000011550b3c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 16 QuartzCore 0x0000000115539086 _ZN2CA11Transaction6commitEv + 486 17のUIKit 0x000000010ef7819b _afterCACommitHandler + 174 18 CoreFoundationの0x000000010df80c37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 19 CoreFoundationの0x000000010df80ba7 __CFRunLoopDoObservers + 391 20 CoreFoundationの0x000000010df767fb __CFRunLoopRun + 1147 21 CoreFoundationの0x000000010df760f8 CFRunLoopRunSpecific + 488 22 GraphicsServices 0x00000001153e5ad2 GSEventRunModal + 161 23 UIKit 0x000000010ef4bf09 UIApplicatio nMain + 171 24 ViewerReviewsApp 0x000000010d738ad2 114 25 +メインlibdyld.dylibは、+ 1 を開始0x0000000111d1392d)

私はこの仕事をするために行うことができます何かはありますか?

答えて

1

私は問題を把握しました。これはView Controllerをインスタンス化する方法でした。

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

    self.presentViewController(commentsView, animated: true, completion: nil) 

ここで、 "seeComments"はストーリーボードのCollectionViewControllerです。

関連する問題