В моем проекте я создал ячейку в UICollectionViewCellUICollectionView Использования Swift
Ее получила прерывающую ошибку приложение из-за неперехваченное исключением
Кодекса следующим образом.
GalleryCell.swift
class GalleryCell: UICollectionViewCell
{
@IBOutlet var titleLabel : UILabel
init(coder aDecoder: NSCoder!)
{
super.init(coder: aDecoder)
}
}
и я использовал эту ячейку в Мой ViewController:
Код следующим образом:
NextViewController.swift
import UIKit
class NextViewController: UIViewController
{
@IBOutlet var collectionView : UICollectionView
var ListArray=NSMutableArray()
override func viewDidLoad()
{
super.viewDidLoad()
for i in 0..70
{
ListArray .addObject("C: \(i)")
}
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section:Int)->Int
{
return ListArray.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath:NSIndexPath)->UICollectionViewCell
{
var cell = collectionView.dequeueReusableCellWithReuseIdentifier("CELL", forIndexPath: indexPath) as GalleryCell
cell.titleLabel.text="\(ListArray.objectAtIndex(indexPath.item))"
return cell
}
func collectionView(collectionView : UICollectionView,layout collectionViewLayout:UICollectionViewLayout,sizeForItemAtIndexPath indexPath:NSIndexPath) -> CGSize
{
return CGSizeMake(66, 58)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Мой вопрос я получаю следующее сообщение об ошибке:
***** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier CELL - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'*** First throw call stack:**
Его получение следующей ошибки Завершение приложения из-за неперехваченного исключения «NSInternalInconsistencyException», причина: «попытаться зарегистрировать класс ячеек, который не является подклассом UICollectionViewCell ((null)) ' – PREMKUMAR
@PREMKUMAR: Проверьте свой класс GalleryCell. Вы сделали это как подкласс UICollectionViewCell? Проблема в самом журнале –
Спасибо, что я получаю ответ. Спасибо, что потратили свое драгоценное время. – PREMKUMAR