1

I have implemented the custom collection view using storyboard. and added a cross button and background image.

When collection view reloading that cross button have been hide for admin and shown for other members which is work perfectly first time.

I have set the tag btn.tag = indexpath.row and assign a function for remove user.

After removing the user and remove the object from the Array when reloading the collection view now that condition I have added for admin to hide button is not working and cross button displayed in all the cells of collection view.

Please anyone help.

        if ([user.type isEqualToString:@"admin"])

        {        [removeBtn setHidden:YES];

                [removeBtn setEnabled:NO];

        }else {

     [removeBtn setHidden:NO];

        [removeBtn setEnabled:YES]; }

Firsttime reloading the collection view result

enter image description here

After Remove Member reloading the collection view result enter image description here

Debug Log After Press Remove Button but cross is now displayed in Admin Item Image.

2016-02-03 11:35:03.620 STT[32132:5629002] Col View 2usertype>    admin
2016-02-03 11:35:03.620 STT[32132:5629002] Hide cross from Admin
2016-02-03 11:35:12.944 STT[32132:5629002] Col View 2usertype>   
2016-02-03 11:35:12.944 STT[32132:5629002] Show cross for Mem
2016-02-03 11:35:17.799 STT[32132:5629002] Col View 2usertype>   member
2016-02-03 11:35:17.800 STT[32132:5629002] Show cross for Mem
4

2 回答 2

0

希望这会帮助你。//注册类

[self.collectionView registerClass:[CustomCell class] forCellWithReuseIdentifier:@"CustomCellIdentifier"];

cellForItemAtIndexPath:(NSIndexPath *)indexPath

// 设置单元格标识符

CustomCell *cell = (CustomCell *)[collectionView dequeueReusableCellWithReuseIdentifier: CustomCellIdentifier forIndexPath:indexPath];
  User *objUser = [self.UserArray objectAtIndex:indexPath.row];
  [cell updateCellData:objUser]; // set tag here and hide/show + button
于 2016-02-02T12:23:01.770 回答
0

删除此行(remove.tag=indexPath.row)后我的解决方案可以正常工作。

于 2016-02-11T11:35:37.590 回答