I am using a custom cell with UICollectionView, I need to define UIButton programmatically per cell.
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath) as! ClinicListCell
cell.title.text = clinicNames[indexPath.row]
cell.subTitle.text = clinicSubs[indexPath.row]
cell.backgroundImageView.image = UIImage(named: clinicImages[indexPath.row])
cell.profileBtn.tag = indexPath.row
cell.profileBtn.addTarget(self, action: Selector(("profileBtnClicked:")), for: .touchUpInside)
return cell
}
And I have defined the following selector method in the same class.
class func profileBtnClicked(sender:UIButton) {
print("Selected")
}
I've tried by removing class/static from the selector method, but it always give me unrecognized selector sent to instance
error, where am I going wrong?
Thanks.