lundi 26 mars 2018

deselect checkmarks from the Collectionview in swift4

I am showing collocation view with multiple checkmarks in main view controller.its working fine

enter image description here

after select checkmarks data showing into next view controller. it is also working. when i back to main view controller which I selected check marks are not unchecked. how to uncheck selected checkmarks.

I used this reference https://github.com/maximbilan/CheckMarkView

@IBOutlet weak var checkMarkViews: CheckMarkView!


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


        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)as! CustomCollectionViewCell

        let row = indexPath.row

        cell.CoutnryImages.downloadImageFrom(link: imagesarray[row] , contentMode: .scaleToFill)

        cell.countrynmae.text = itemsarray[row]

        cell.checkMarkViews.setNeedsDisplay()

      return cell

    }


    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

        let cell = CollectionView.cellForItem(at: indexPath) as! CustomCollectionViewCell

        var indexpathvalues = indexPath.row   

        cell.checkMarkViews.checked = !cell.checkMarkViews.checked

        if cell.checkMarkViews.checked == true
        {

           PassedID.append(idarray[indexpathvalues])
            _selectedcell.add(indexpathvalues)

        }
        else
        {
        if PassedID.isEmpty
            {
                print("no Item found ")
            }
            else
            {
                 _selectedcell.remove(indexpathvalues)
                PassedID.removeLast()
            }

        }

    }

    @IBAction func Addbutton(_ sender: UIBarButtonItem) {

              performSegue(withIdentifier: "next", sender: self)

    }

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        let vc = segue.destination as? nextViewController

        vc?.arrayvalues = self.PassedID

        _ = navigationController?.popViewController(animated: true)       

    }

how to uncheck the multiple selection after back to main view controller  




Aucun commentaire:

Enregistrer un commentaire