searched already some possible fixes but all did not solve mine.
i keep clicking the cell in the uitableview rather than the buttons inside it.
here is my code:
There is another potential cause of problems like this one, and that is UITableViewCells
now have a contentView
. This can and will be placed in front of other views in your custom table view cells in order to pick up touches and detect cell selection. In doing so, it may block touches to any views behind it. I've especially noticed this annoyance when creating cells using nibs.
The accepted means for dealing with this is to ensure that all subviews are added not to the tableview cell itself, but to its contentView
. This is a read-only property that adjusts its own frame under certain circumstances, for example when slid sideways to reveal the delete button, or during editing mode. You should therefore ensure that any items you do add to the contentView
are intelligently sized and have the correct resizing behaviour.
Also be aware that by adding cells to the contentView
, you may yourself block touches to it and thus prevent the cell from being selected. I personally try not to allow cell selection in tableviews containing cells with custom user-enabled controls. It only leads to confusion and awkward interfaces. In fact, I'm seriously considering replacing all UITableViews
in my future projects with UICollectionViews
, which are far more adaptable.
-Ash