我做了一个自定义collectionview单元格。我已经把它作为集合视图的头部通过该代码:Swift 3.0:自定义CollectionView标题按钮点击
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionElementKindSectionHeader {
let cell = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "HeaderCell", for: indexPath) as! GridHeaderCollectionViewCell
cell.pagePluginBtn.tag = 0
cell.tag = 0
cell.nameLabel.text = pageRecord["GroupName"] as? String
cell.pagePluginBtn.addTarget(self, action: #selector(TappedOnPagePluginBtn(sender:)), for: .touchUpInside)
return cell
}
abort()
}
func TappedOnPagePluginBtn(sender:UIButton){
print("in plugin")
}
小区被定义为:
class GridHeaderCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var pagePluginBtn: UIButton!
}
TappedOnPagePluginBtn()
的是没有得到在所有调用。有没有什么办法让按钮在collectionView的headerView中可点击?