How to put UIGestureRecognizer in front if several views with gestures overlaps - iphone

I have two views that have tap gesture recognizers attached. The first view accepts touches while the second one is hidden. After some time, I'm making the second (with attached gesture) view visible. The problem is that, still, only the touches of the first view are handled, despite the second view is in front :(

Sorry, forgot to put "user interaction enabled". I'm drawing my views and other stuff with interface builder, therefore I have missed that :)

Related

Avoiding touch gesture conflicts between two different views

Let me emphasize that there are two views that overlap and I want handle the touch gestures of the view on top.
The UIGestureRecognizeDelegate methods work for conflicting gestures within one view not two views from what I have read. Please don't link me to those threads without explaining.
This issue is occurring between the toolbar items and an image view with gestures attached to it.
In the image above the bar buttons cannot be touched.
Other apps handle this case without issues. If I touch a bar button it would work and if I drag the view on the non-overlapped parts I would be able to drag it.
How can I achieve this ?
Currently the image view has gestures attached to it (one for testing, its a pan).
Update
As requested here is a Gif.
Notice how the buttons are not responding when there is a view under the toolbar.
The issue was that I was using view.layer.zPosition, apparently changing the zPosition does not change the position of view is the subview hierarchy (which was something that I assumed).
Source: https://stackoverflow.com/a/15807250/3366784

SWRevealViewController Pan gesture is not working when the from view is scrolling enabled

I have a side menu which is impelemented by SWRevealViewController and my frontView has a collection view.
SWReveal works fine by tap on menu button, but the pen gesture is not working on collection view (which has a horizontal scrolling enabled).
can any one help me to force collection view to accept the pen gesture of the SWReveal?
SWRevealViewController's gesture controller and collection view are been clashing that's why the problem occurs. Other than that as per my view there is no practical way to identify what user wants to open by the gesture.
But Client needs a solution and the image shows it! keep user interaction ON of the view.
Let me know if you find anything else.
Best of luck.
Add below code in viewDidLoad
self.view.addGestureRecognizer(revealViewController().panGestureRecognizer())

UIButton disabled when covered (or semi covered) by a view

I have a view that holds some UIButtons. Another view covers and hides the buttons. When the top view slides off to reveal the buttons (with an animation).. the UI draws the buttons grayed out until the top view no longer covers or overlaps the buttons at all.. causing an undesirable flicker from gray to the normal button color (white).
is there a way to keep the UIButton from rendering itself disabled while covered or semi covered by another view?
I dont think that its correct that a button is disabled while covered. What is happening is that when its covered, touch events are prevented from getting to the button, so the button cant get pressed. If the button is only partially covered, touch events to that part that are not covered can be received by the button and the button can be depressed. If you really wanted the button to work while it was covered (maybe you can relayer your views so the button is in front of the view instead of behind it?) you could hack your view and void its hit testing so it doesnt capture the touches.
Well, in lieu of actually finding the correct answer, I simply swapped out the buttons with UIImageViews and attached UITapGestureRecognizers to them... this solved the problem.

How to recognise gesture in superview?

I have a view (parent) and a subview (child). The child is a UIControl, responding to UIControlEventTouchDownInside, the parent has a swipe recogniser. I would like to catch swipes even if they start in the child.
Question: how can I recognise the swipe before the tap? Is there any way to tell iphone that gestures in the parent come before gestures in the child?
Thanks for your help!
Edit
I just changed the child to be a UIControl (instead of using a tap recogniser). I'm not sure this matters much to the answer to this question but I thought I'd mention it anyway.
Edit 2
In response to the two answers I have added the tap recogniser to the child again and tried to delay (and fail) the tap recognition so that I can swipe across the big view (parent) containing the child. No luck so far.
Edit 3
I would really like to keep the child a UIControl and use UITouchDownInside rather than a tap recogniser because I want to use the down event rather than the up event.
Edit 4
Now the swipe gets detected but in the child, none of the following gets detected:
UIControlEventTouchDragOutside, UIControlEventTouchDragExit , UIControlEventTouchCancel
and I need at least one of these to detect when the user doesn't actually mean to tap on the child : /
Check the - (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer in UIGestureRecognizer. To tap, the swipe gesture has to fail.
You can use the [swipeGesture delaysTouchesBegan] message to delay the touch events being delivered to the child control.

I have a UI Scroll View with UIButtons on top. How do i make it scroll when they touch and drag the buttons?

I want something similar to how the iPhone homescreen works. I have my scrollview inside my main view, which scrolls to the right, but when you touch on the UIButtons, they become highlighted and dragging means they don't end up getting pressed but also the scrollview doesn't end up scrolling. It doesn't do this on the homescreen. How can i make it similar to this?
A touch-down-drag is a completely different event. Apple doesn't support this directly—you'd have to code it in—start tracking the touches using the gesture responders as soon as a touch-down-inside is detected, then scroll the same amount, and stop scrolling at a touch-up-outside (or inside). This would most likely fall under the category of unusual use of interface elements, and could very well get you rejected.
I think this is a better answer to the question:
UIScrollview with UIButtons - how to recreate springboard?