Reputation: 55
I had a similar problem before, but this time the solution to the problem continues to elude me.
So I made a dynamic tableview with prototype cells, and put in buttons (the gray background views with blue letters are buttons).
The problem is that the buttons are not clickable once the simulator starts. I checked multiple times that the issue is not related with isUserEnabled, nor is it related to the order of the subviews (the buttons are the highest in the hierarchy when I checked with the 3D debugger).
I am guessing that the problem might come from this being a dynamic cell, but what seems weird to me is that the textfield "Mastery to Add" responds to my touches, although the buttons don't.
What could be the source of the problem?
Thank you.
Upvotes: 0
Views: 524
Reputation: 66
Before iOS6
UITableViewCell>
| <UITableViewCellContentView>
| | <UILabel>
After iOS7
<UITableViewCell>
| <UITableViewCellScrollView>
| | <UITableViewCellContentView>
| | | <UILabel>
iOS7 or later processing method is different when event processing when button is clicked.
Add the button action dynamically as follows:
cell.btn.tag = indexPath.row
cell.btn.addTarget(self, action: #selector(MainVC.buttonAction), for: UIControlEvents.touchUpInside)
Upvotes: 3