在集合視圖中我選擇了一個單元格,但它被選中了多個單元格。UiCollectionview允許單個選擇特定單元格
- (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
你能添加一些代碼 –
在選擇信息按鈕,我是選擇了一個單元,但它選擇了下行信也。 –
我瞭解,對於您的代碼,如果([sender isSelected]){[sender setSelected:NO];我們無法找到問題 –