I have an application with three buttons (actually UIView
's) laid out horizontally underneath the navigation bar.
The three buttons are of substantial enough size (larger than the back button, for example), however they won't respond to touches when the hit is in the top third part, roughly.
I'm aware that this area directly underneath the nav bar is sort of 'reserved' for the back button and other UINavigation items having a touch area that expands beyond the navigation bar (by quite a significant margin), however in some instance there isn't even a navigation item nearby to steal the event, and my views still don't respond.
The weird thing is that I am getting a call to the hitTest
method in my UIView, just never a touchesBegan/Ended/etc.
The result is that it is very difficult to press the buttons and if one is anywhere near a UINavigationItem
, the item will steal the event, even though in hitTest
I am returning the correct UIView
to the system.
Unfortunately I am the implementer and not the designer so a design change is a last resort.
Any ideas? Thanks!
Had the same problem and the above answers are good and they point to a concise solution.
The same answer for the swift version:
You have to subclass your UINavigationBar and in your CustomNavigationBar do this:
Info about how to subclass UINavigationBar you can find here.
The code provided by @Andrei will cause controller stack inconsistency on iOS 7 when quickly push and pop controllers. The system itself will change the
userInteractionEnabled
property before and after push/pop animations. Here is how I fixed this issue.I dont think that it is the problem, but did you bring the button subviews to the front?