UiCollectionview 允许单个选择特定单元格 [英] UiCollectionview allow single selection for specific cell

查看:32
本文介绍了UiCollectionview 允许单个选择特定单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在集合视图中,我选择了一个单元格,但它选择了多个单元格.

In Collection view i am select the one cell but it is selected multiple cells.

- (UICollectionViewCell *)collectionView:(UICollectionView      *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
CustomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    cell.Selectitems.tag=indexPath.row;
[cell.Selectitems addTarget:self action:@selector(selectitem:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)selectitem :(UIButton *)sender{
if ([sender isSelected]) {
    [sender setSelected: NO];
    cell.check = YES;
     [cell.Selectitems setBackgroundImage:[UIImage imageNamed:@"product-uncheck.png"] forState:UIControlStateNormal];
}else{
        [sender setSelected: YES];
        cell.check = YES;
      [cell.Selectitems setBackgroundImage:[UIImage imageNamed:@"product-check.png"] forState:UIControlStateNormal];
}
}

检查下面我的图片链接[1]:http://i.stack.imgur.com/WIgDH.png

Check bellow my image link [1]: http://i.stack.imgur.com/WIgDH.png

推荐答案

这里是完整的代码,可以满足你对collectionview

Here is the complete code which may satisfy your requirement for checkbox with collectionview

https://www.dropbox.com/s/e43zk55surlwjlk/CollectionCkeck.zip?dl=0

这篇关于UiCollectionview 允许单个选择特定单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆