我有一个集合视图,有两个自定义单元格,一个用于网格,一个用于列表,我希望能够触摸单元格并选择它们,如果要删除或共享它们,我现在想要的只能选择和deselct他们,生病我的代码下面的结果是当我触摸一个单元格所有单元格被选中!这是代码:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
if isGridSelected {
let cell:cell2_Class = collectionView.dequeueReusableCellWithReuseIdentifier("cell2", forIndexPath: indexPath) as! cell2_Class
cell.listImage.image = imageArray[indexPath.row]
if flag == true {
cell.layer.borderColor = UIColor.blueColor().CGColor
cell.layer.borderWidth = 3
cancelButton.hidden = false
} else {
cell.layer.borderColor = UIColor.clearColor().CGColor
cancelButton.hidden = true
}
return cell
} else {
let cell:PhotoCollectionCell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! PhotoCollectionCell
if flag == true {
cell.layer.borderColor = UIColor.blueColor().CGColor
cell.layer.borderWidth = 3
cancelButton.hidden = false
} else {
cell.layer.borderColor = …Run Code Online (Sandbox Code Playgroud)