Reputation: 520
I would like to use the accessory type in Table View Cell not just an accessory, but also as a button.
tableViewCell.accessoryType = UITableViewCellAccessoryType.DetailButton
For example I'm using detailButton for accessoryType which when I touch it, I could trigger an event (eg. pop up alert). I have tried make a custom button with and put it on table view cell as an accessory view, but I would like to know if using default accessory type is possible. Is there anyway I could do that?
Thanks!
Upvotes: 1
Views: 262
Reputation: 318774
If you use the accessoryType
with a type of DetailButton
or DetailDisclosureButton
, then you can implement the UITableViewDelegate
method of tableView:accessoryButtonTappedForRowWithIndexPath:
.
This method is called when the user taps on the accessory button.
If you want any sort of custom UIButton
then you need to create the button and set it as the cell's accessoryView
. Setup the UIButton
like you would any button to respond to user taps.
Upvotes: 1