IOS_OC_網(wǎng)格的批量編輯(選中、反選、全選、刪除)

============================================================================================================================================================================================================================================================================

根據(jù)行業(yè)慣例,開頭應(yīng)該放張gif。但是由于之前裝的gif工具不能用了。放兩張圖片自己腦補吧?。?!!

Simulator Screen Shot - iPhone 11 - 2020-04-14 at 15.26.05.png
Simulator Screen Shot - iPhone 11 - 2020-04-14 at 15.26.18.png

基本上就是這個樣子了。

實現(xiàn)步驟:
自定義網(wǎng)格cell中定義一個Bool變量,用來記錄當前cell狀態(tài);
cell的代理方法中根據(jù)編輯狀態(tài)控制cell的選擇圖片是否隱藏;
cell的觸發(fā)事件代理方法中為cell的圖片賦值;

核心代碼:

       cell.selectImgV.hidden = NO;
         if (self.isAllSelect == YES) {
             cell.selectImgV.image =  [UIImage imageNamed:@"select_yes"];
             cell.isSelectGo = YES;
         }else{
             cell.selectImgV.image =  [UIImage imageNamed:@"select_no"];
             cell.isSelectGo = NO;
         }
        CustomCollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
        if (cell.isSelectGo == YES) {
            cell.isSelectGo = NO;
            cell.selectImgV.image =  [UIImage imageNamed:@"select_no"];
            [self.selectArr removeObject:self.dataArr[indexPath.row]];
        }else{
            cell.isSelectGo = YES;
            cell.selectImgV.image =  [UIImage imageNamed:@"select_yes"];
            [self.selectArr addObject:[NSString stringWithFormat:@"%@",self.dataArr[indexPath.item]]];

        }

也就沒啥玩意了還有個Demo

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容