Reputation: 5
I have a photos collection view with different section header with different items but i want to add an action button into the last cell of a section which will take a photo and will be added the photo to the section cell and only last cell of the section will be contain the action button .I attached a similar photos of screen in the link below.
Upvotes: 0
Views: 511
Reputation: 1062
@User,
Add action(.touchUpInside) on button in header for all section and while performing events you can detect that if that section is last than perform task otherwise return.
e.g
section.tempButton.tag = indexPath.section
section.tempButton.addTarget(self, action: #selector(performTask), for: .touchUpInside)
then it will call the selector when touched
@objc func performTask(sender:UIButton){
if sender.tag == lastSection{
//perform task
}
}
Upvotes: 1