How to disable the selection on UITableViewCell's accessory view only?

674 Views Asked by At

My UITableViewCell has an accessory view of UIButton on the right edge of the cell. However, the button might not be available to an user and thus I shall disable it via self.myButton.enabled = false.

While this makes the cell selection work as usual however, now the selection also reacts to the tap on the button. In other words, while the button is disabled and the user still taps on the button, the tap is now responding to the didSelectRowAtIndexPath: method.

This is not what I want, since it might confuse my users at times. So I want to implement it as follows:

  • When the button is available, tapping the cell and tapping the button execute different methods respectively (which I implemented and worked).

  • When the button is unavailable, tapping the cell works only on the part of where the button is not located.

Is it possible to set the functionality here?

0

There are 0 best solutions below