当用户LOCATION 'hdfs://hadoop1:9000/logHive/unLock/${hiveconf:logdir}'
(按钮)删除单元格时,我想从UICollectionview
删除单元格。
这是我的代码:
touchUpInside
我做错了什么?
答案 0 :(得分:-2)
为您的删除按钮设置标记以获取当前单元格/知道您点击的单元格
cell.deleteBtn?.tag = indexPath.row
cell.deleteBtn?.addTarget(self, action: #selector(yourVCName. deleteColor(_:)), for: .touchUpInside)
并调用
@IBAction func deleteColor(_ sender: UIButton){
print("Button pressed ")
// continue your work
var hitPoint = sender.convert(CGPoint.zero, to: yourCollectionViewName)
var hitIndex: IndexPath? = yourCollectionViewName.indexPathForRow(at: hitPoint)
self.items.remove(at: hitIndex.row)
self.yourCollectionViewName.performBatchUpdates({
self.yourCollectionViewName.deleteItems(at: [hitIndex])
}) { (finished) in
self.yourCollectionViewName.reloadItems(at: self.yourCollectionViewName.indexPathsForVisibleItems)
}
}