I have a UITableViewCell
with a button inside of it. (made through IB).
Now what I'd like to do is the following:
- When pressing the
UITableViewCell
, I'd like to trigger asegue
. - When pressing the
UIButton
, I'd like to trigger an action.
However, what actually happens is that the UITableViewCell
gets selected when the button is pressed, instead of the desired result.
Is there a way around it that enables both actions at the same time?
Thanks.
-- Edit
I'd like to be able to select the table cell still, AND be able to press the button. So disabling selection wouldn't work.
-- As requested, the code for the cellForRowAt:
method
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: PersonTableViewCell.identifier, for: indexPath) as! PersonTableViewCell
if ( indexPath.row < (self.searchResult.count)) {
cell.configure(searchResult[indexPath.row])
}
return cell
}
Then, inside of the configure function of the cell
, a UITapGestureRecognizer
is created on the button that triggers the following function:
func follow(profile: User) {
self.followButton.isSelected = !self.followButton.isSelected
profile.toggleFollow(callback: { _ in })
}