Button in UITableViewCell not responding under ios 7

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 file.

Could anyone give me some suggestions? Thanks in advance.


Solution 1:

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.

Solution 2:

Calling [cell bringSubviewToFront:button] after loading the cell from nib solved this for me.

Solution 3:

I have also struggled with this problem and I did a lot of research over the different answers on stackoverflow and internet, the solution is different depending on the source of the problem. For the most case, you need to do the following with the element that is supposed to take user action (tap/click etc.):
myButton.userInteractionEnabled = YES;

Particularly for UILabel/UIImageView, by default the userInteractionEnabled flag is NO.

If you are loading the view from a xib, you need make sure, from the custom cell view, content view, and the element you want the user action enabled, all have the check box checked:
enter image description here

In the example above, DeviceViewCell, Content View and Button element all have "User Interaction Enabled" check box checked.
If the custom cell is implemented as a sub class of UITableViewCell, and the custom cell view is loaded from another xib file dynamically, you HAVE TO DO one more thing which is confusing to most of the people but I will explain why later on:
In the custom cell's initialization method, you need to do the following:
self.contentView.userInteractionEnabled = NO

where self is the subclass of UITableViewCell you created. Again, IF the custom cell is implemented as a sub class of UITableViewCell, and the custom cell view is loaded from another xib file DYNAMICALLY, you need to do the above. Here is the explanation:

self.contentView is NOT the same Content View you see in Interface Builder, it is created by the system as the default content view that is on TOP of every other views/elements within your custom cell view, and it obscures the rest of views in the view hierarchy. Hence, you will need to disable the user interaction for it before the UI elements in the custom cell view can receive user interaction events. Hope this helps. If you have a better explanation I would love to hear it :-). Again is is my observation and there could be other reasons. Discussion is welcome!