小编Con*_*rry的帖子

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 …

ios uicollectionview swift

5
推荐指数
1
解决办法
4537
查看次数

选择数组中的中间值 - Swift

我试图确保中间值 Lists 是构建我的应用程序时看到的第一个视图。Xcode 提供if let firstView = viewList.firstif let firstView = viewList.last但我无法练习如何选择中间值。

lazy var viewList:[UIViewController] = {
    let sb = UIStoryboard(name: "Main", bundle: nil)

    let lists = sb.instantiateViewController(withIdentifier: "Lists")
    let reminders = sb.instantiateViewController(withIdentifier: "Reminders")
    let todo = sb.instantiateViewController(withIdentifier: "To Do")

    return [reminders, lists, todo]
}()

override func viewDidLoad() {
    super.viewDidLoad()

    self.dataSource = self

    if let firstView = viewList.first {
        self.setViewControllers([firstView], direction: .forward, animated: true, completion: nil)
    }
}
Run Code Online (Sandbox Code Playgroud)

arrays uipageviewcontroller swift

4
推荐指数
1
解决办法
3677
查看次数