dimanche 19 février 2017

how to use if else statement having two collection view from different controller to go to detail view controller?

I have two view controllers with collectionviews each, the goal here is when I click the photo of photostreamcontroller(men) or the artsviewcontroller it will go directly to the detail viewcontroller, how do I use the if else statement here in numberOfItemsInSection and CellForItemAtIndexPath, the code right now is working in photostreamcontroller but the artcontroller is still not working because it is not fixed in numberOfItemsInSection and CellForItemAtIndexPath

import UIKit

class StreamDetailController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate{

        var menImage = [Men]()
        var artsImage = [Arts]()

    @IBOutlet var extraCells: UICollectionView!

    var streamPhotos = Photo.allPhotos()
    var menDataSource : MenDataSource!

   override func viewDidLoad() {
        super.viewDidLoad()

    self.setNeedsStatusBarAppearanceUpdate()
    self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "back"), style: .plain, target: self, action: #selector(UIViewController.back))
    self.navigationItem.leftBarButtonItem?.tintColor = UIColor.white
    }

    func didMovedToIndex(index:Int)
    {
        print("did moved at Index : ",index)
    }
    override var prefersStatusBarHidden: Bool {
        return false
    }

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
          return self.menImage.count
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        let cell = extraCells.dequeueReusableCell(withReuseIdentifier: "Cells", for: indexPath) as! ExtraViewCell
        let men = menImage[indexPath.item]
            cell.boxImage.image = men.image

        return cell
    }

    @IBAction func itemIcon(_ sender: Any) {

    }
   }

ViewControllers

Aucun commentaire:

Enregistrer un commentaire