2016-07-08 18 views
1

すべてを選択し、すべてを選択してcollectionViewのすべてのセルを選択解除し、すべてを選択解除したいUIButton? 誰かを助けてください。UICollectionViewCellでチェックボックスの画像を選択または選択解除して表示しますか?

//Delegate Method cellForItemAtIndexPath 
func collectionView(collectionView: UICollectionView, 
cellForItemAtIndexPath indexPath: NSIndexPath) -> 
UICollectionViewCell 
{ 
    //Get a reference to our storyboard cell 
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(
                  "pickSomecell", 
        forIndexPath: indexPath) as!  pickSomeGridViewController 
    //Show Images in grid view 
    cell.cellImage.image = self.arrAllOriginalImages[indexPath.row] as? UIImage 
    cell.toggleSelected() 

    //return cell. 
    return cell 
} 

おかげ

+0

としてやってみては? –

+0

はい@BhumitMehta しかし、私は一緒にすべての画像を選択したいと思います。 – kishor

+0

CellForItemAtIndexPathにコードを投稿できますか? –

答えて

1

は、あなたが選択か非選択として示したいUICollectionViewCellのチェックボックスのイメージを持っているわけでくださいフォロー

var isSelectAll=false 


    func collectionView(collectionView: UICollectionView, 
         cellForItemAtIndexPath indexPath: NSIndexPath) -> 
     UICollectionViewCell 
    { 
     //Get a reference to our storyboard cell 
     let cell = collectionView.dequeueReusableCellWithReuseIdentifier(
      "pickSomecell", 
      forIndexPath: indexPath) 
     //Show Images in grid view 

     if isSelectAll { 

      cell.cellImage.image = selectedImage; 
     }else{ 
      cell.cellImage.image = desselectedImage; 
     } 


     return cell 
    } 

@IBAction func selectAllcell(sender: AnyObject) { 

    isSelectAll=true 
    collectionView.reloadData() 

} 

@IBAction func deselectAllcell(sender: AnyObject) { 

    isSelectAll=false 
    collectionView.reloadData() 

} 
+0

私はお試しください。 ありがとうございました。 – kishor

関連する問題