Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIButton not working correctly in iOS 7

I have a problem with a UIButton that works perfectly well in iOS6, but fails to respond to touch events in iOS7 up to a certain point. To clarify please see below image:

ios7_button_issue

The button that fails is the "Discard All" button that is in the UIView. (Please note, this button is only disabled temporarily and that is NOT the issue. I just don't have a screenshot of the newest test where the button is enabled")

This button ignores all touches, unless one first presses the "Discard" or "Retry" buttons in the UITableViewCell. (This does cause a reload of the view controller, which triggers the lifecycle methods like ViewDidLoad to be called again.) After either the "Discard" or "Retry" buttons in the table view cell have been pressed, the "Discard All" button starts functioning correctly.

The view and the "Discard All" button are build on the Controller's XIB file and not in code. This only fails on iOS7, and starts working as soon as the taleview cell buttons are touched.

Anyone have any ideas?

Thanks!

like image 904
Daniel Retief Fourie Avatar asked Sep 30 '13 14:09

Daniel Retief Fourie


1 Answers

I found the solution last night. Okay, so what happens is that I put the above table view and UIView elements onto a target frame.

I'm not 100% sure, but it seems that in iOS6 the buttons respond to events irrespective of where they are placed. For some reason in iOS7 when the button sits outside of the frame it is supposed to be in, it ignores touch events, even though it does get displayed.

I solved the problem by positioning the view's frame in the correct place so it overlays the button.

If I can find any documentation around this, I will post here.

Thanks!

like image 170
Daniel Retief Fourie Avatar answered Sep 30 '22 23:09

Daniel Retief Fourie