我在IB创建的标题单元格中有一个按钮。我添加动作,但我无法触发。这段代码;
func collectionView( _ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
switch kind {
case UICollectionElementKindSectionHeader:
let cell = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! ProfilePhotoHeaderCell
cell.lblFavCount.text = user.favdCount
let countFoto = ((user.photos?.count)!)
cell.lblFotoCount.text = countFoto.description
cell.btnAddPhotos.isUserInteractionEnabled = true
cell.btnAddPhotos?.addTarget(self, action: #selector(ProfileController.myAction(sender:)), for: .touchUpInside) // add selector
return cell
case IOStickyHeaderParallaxHeader:
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerCell1", for: indexPath) as! ProfileParallaxHeaderCell
return headerView
default:
assert(false, "Unexpected element kind")
}
}