Monday, April 18, 2016

Unresponsive UIButton, and the OTHER enable button!

Just spent a couple of hours with the simplest of issues - a UIButton that was not responding to clicks.  This is almost the most frustrating kind of issue.  A seemingly really simple thing, and Ive been doing iOS for 5 years now, and must have implemented 1000 UIButtons succesfully.

There are several very common reasons why a UIButton can be unresponsive, such as : userInteractionEnabled is not set to YES (either in NIB or code).  Theres an invisible UIView of some kind above the button in the view hierarchy, and it is not passing on touches to objects below it.  Then theres more obscure ones such as : you have implemented an animating image on the button, and it is interfering with touches.  Yes - Ive had that issue too.

But Ive never before had this one.  Theres another tick box, in the storyboard's UIButton panel, in the 'Control' section.  Here you set the alignment of the text content - and just under there, a separate 3 booleans are titled : Selected, Enabled and Highlighted.

And my issue, after two hours of fiddling, turned out to be : that Enabled tick box must be ticked.

I have never come across that issue before.  I dont actually know why this is suddenley having an effect on my UIButton.  If anyone would care to enlighten me more about this (almost) hidden but essential little tick box, I am all ears!

Meanwhile, make sure this is ticked.


No comments:

Post a Comment

Social Network with Firebase 3 - Infinitely scrolling UITableView of Firebase Items

Ive already talked about the basics of a Firebase social network project , and adding posts in two other articles. Here I want to explain ...