这使我疯了,我一直在阅读SO几个小时,并尝试了一切,不能让这个按钮选择器工作。这应该不难。收藏按钮选择器查看单元格
Inside CellForItemAt我已经设置了按钮标签并尝试调用按钮。
cell.deleteCellButton.tag = indexPath.item
cell.deleteCellButton.addTarget(self, action: #selector(deleteCellButtonTapped(sender:)), for: UIControlEvents.touchUpInside)
我试过(_ :)“deleteCellButtonTapped:”和其他任何数量的括号组合和我仍然得到无法识别的选择。我不知道为什么自动完成建议(发件人:)我从来没有见过这个。
那么我的按钮功能:
func deleteCellButtonTapped(sender: UIButton!) {
self.packArray.remove(at: sender.tag)
print(packArray.count)
self.outerCollectionView.deleteItems(at: [IndexPath(item: sender.tag, section: 0)])
self.outerCollectionView.reloadData()
self.outerCollectionView.layoutIfNeeded()
}
#selector(自deleteCellButtonTapped(发件人:))为我工作。 – Anuraj