I have one tableview and each cell contains one button. It\'s working pretty well all iOS versions but 7. I don\'t know what\'s going on. The cell is constructed in one xib
What worked for me is this:
contentView.userInteractionEnabled = NO;
called after loading my custom cell from nib. It looks like this content view is created and set as a top-level child view after creating views defined in the nib file.
I checked everything but I made silly mistake of In storyboard my button's superview was below some other view. so touch was not passing to my button.
In my case, I need to check the "User Interaction Enabled" for the cell itself (not just the contentView) as well. But as noted in other answers, there could be multiple reasons for why this is happening so I am sure this won't work for every case.
The problem is that your nib is not containing a contentView, as required since the iOS 8 SDK (I'm writing by experience, don't have a viable source, sorry).
When you add an UITableViewController
to a storyboard, an UITableViewCell is added to it's UITableView
automatically. If you take a look at this UITableView
, you'll see a contentView
in it.
So when you subclass an UITableViewCell
and create it with a .xib, you'll have to click&drag a UITableViewCell
to the xib instead of the default UIView
. Then don't forget to set the File Owner class and the UITableViewCell
class to your subclass.
None of these answers worked for me.
The only way I was able to fix this problem was to set the table cell selection from single to none. After that, I was able to receive button call backs.