Swift 错误 - 使用未声明的类型“单元格” - 集合视图

Con*_*rry 5 ios uicollectionview swift

Swift 编程新手,我的错误的原因是什么,我该如何解决?非常感谢。

导入 UIKit
导入照片


类 PhotosViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource , UICollectionViewDelegateFlowLayout, UIImagePickerControllerDelegate, UINavigationControllerDelegate

{

    @IBOutlet 弱 var myCollectionView:UICollectionView!


    var imagesArray = [UIImage]()

    覆盖 func viewDidLoad(){
        super.viewDidLoad()
        myCollectionView.delegate = self
        myCollectionView.dataSource = self

    }

    @IBAction func addPhoto(_ sender: AnyObject) {

        让选择器:UIImagePickerController = UIImagePickerController()
        picker.sourceType = .photoLibrary
        picker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .photoLibrary)!

        选择器.delegate = self
        picker.allowsEditing = false
        self.present(选择器,动画:true,完成:nil)
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! 细胞


        cell.configurecell(imagesArray[indexPath.row])

        返回单元格

    }


    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection 部分: Int) -> Int {

        返回 imagesArray.count

    }



    func imagePickerController(_picker: UIImagePickerController, didFinishPickingMediaWithInfo 信息: [String : Any]) {
        if let pickimage = (info[UIImagePickerControllerOriginalImage] as? UIImage){
            imagesArray = [pickedimage,pickedimage,pickedimage]//将三个选定的图像存储在您的数组中
            myCollectionView.reloadData()
        }
        解雇(动画:真实,完成:无)
    }
}

Md *_*vez 3

您必须在属性检查器中设置一个标识符。

  1. 单击故事板中的整个单元格。

  2. 选择属性检查器

  3. 提供标识符名称(例如标识符=单元格)

    如需更多说明 - 第一张图片
    第二张图片