Mystery Buttons in UITableViews


Gerriet M. Denkmann
 

iOS 12, Xcode 10.

I have two subclasses of UITableViewController, and the tableView of each has a row with a UIButton.
Both subclasses look absolutely identical (I have checked this in Xcode at least a dozen times) but still:
• One button works as expected,
• but the other one does not react to tappings at all (not dims for a short time, not sends its action methods). And yes: it has valid targets and methods. Doing sendActionOn: just work fine.
But I really want the button to react to tappings.

Where should I look for an explanation?

Gerriet.


Alex Zavatone
 

Did you prepare the cells for reuse?

Run the app in the simulator and enable the highlight for the views. I’ll bet that as soon as you scroll the table view, some cells are getting ghost buttons appearing in them.

It that what’s happening?

On Sep 26, 2018, at 8:58 PM, Gerriet M. Denkmann <g@mdenkmann.de> wrote:

iOS 12, Xcode 10.

I have two subclasses of UITableViewController, and the tableView of each has a row with a UIButton.
Both subclasses look absolutely identical (I have checked this in Xcode at least a dozen times) but still:
• One button works as expected,
• but the other one does not react to tappings at all (not dims for a short time, not sends its action methods). And yes: it has valid targets and methods. Doing sendActionOn: just work fine.
But I really want the button to react to tappings.

Where should I look for an explanation?

Gerriet.




Gerriet M. Denkmann
 

On 27 Sep 2018, at 09:00, Alex Zavatone via Groups.Io <zav=mac.com@groups.io> wrote:

Did you prepare the cells for reuse?

Run the app in the simulator and enable the highlight for the views. I’ll bet that as soon as you scroll the table view, some cells are getting ghost buttons appearing in them.

It that what’s happening?
No ghosts, no gremlins.

Looking at the table views again (after a good night’s sleep), I finally discovered that the prototype cell for the row with the button did *not* have:

Interaction ✔️ User Interaction Enabled

So, no big surprise that there was no user interaction (i.e. pressing of buttons) in this row.

A rather stupid mistake on my part. And sorry for the noise.


On Sep 26, 2018, at 8:58 PM, Gerriet M. Denkmann <g@mdenkmann.de> wrote:

iOS 12, Xcode 10.

I have two subclasses of UITableViewController, and the tableView of each has a row with a UIButton.
Both subclasses look absolutely identical (I have checked this in Xcode at least a dozen times) but still:
• One button works as expected,
• but the other one does not react to tappings at all (not dims for a short time, not sends its action methods). And yes: it has valid targets and methods. Doing sendActionOn: just work fine.
But I really want the button to react to tappings.

Where should I look for an explanation?
To repeat myself: make sure to have:
Interaction ✔️ User Interaction Enabled

Gerriet.