我在UICollectionViewCell中有复选框图像,我想显示为选中还是未选中?

时间:2016-07-08 09:46:27

标签: ios swift grid uicollectionview

我想选择全部并取消选择Preferences - General的所有单元格,使用全选并取消全选collectionView? 请帮助任何人。

UIButton

谢谢

1 个答案:

答案 0 :(得分:1)

尝试按照以下步骤进行操作 -

 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()

}