No button events in iphone 5 simulator

When I test my application running on the iPhone 6 simulator, everything works as expected. If, however, I test it on an iPhone 5 or iPhone 5.1, I can’t get it to trigger events with buttons. Im using Xcode 4.5.2 without using storyboards, and I tested with simple buttons with actions such as:

- (IBAction)test:(id)sender { NSLog(@"YEES"); } 

And the actions are connected using drag and drop in the interface builder. I just can't get him fired. Do you have any ideas on what might be the problem?

January 18th update:

If I do a β€œnormal” click on a button in the iPhone 5 / 5.1 simulator, nothing happens. If I am a little β€œslow”, press the button, the button will be pressed / selected. If I make a "very slow" click, for example, keeping the button pressed for 3 seconds, I get a button click event! How is this possible?

+4
source share
3 answers

I found a solution for my case - I added a UITapGestureRecognizer to the UIView container, and it hooks events before the UIButtons, and it needs some time to crash before the buttons can handle the tap ... But it’s strange that everything works fine in iOS 6

To avoid this, we can simply call:

 [tapRecognizer setCancelsTouchesInView:NO]; 
+3
source

I really suspect that this could be a view overlap problem. Please color your views that you use on view controllers and see if your image overlaps your button or not.

0
source

I had a similar problem with the iPhone 5s simulator. Through trial and error, I realized that the height of the button in the simulator is 0 or, otherwise, a small number ... The first key is that when I changed my background color, the background did not appear in the simulator (on large simulators, like 6 or 6 plus, he showed as a thin line instead of full height). Then, when I added a height limit, he began to accept click events. This helped me identify the problem, but it was not the solution I was looking for. Initially, I laid down the button with no size restrictions, so the actual size should have been determined by its internal size. Therefore, instead of the height limit, I changed the vertical compression resistance of the button to "required." This fixed the problem.

0
source

All Articles