moving a view under finger - ios

I have a view-chain; the first view is in the second, the second is in the third and so on.
I want to move the top most view under my finger and I did some logics to handle this in touchesBegan:touchesMoved:...
The problem is that each view has different gestures and if I try to move the top most view, the views behind it also respond to the moving. Is there any way to disable the gesture except the top most view when I am trying to move it?
Also I do not want the top most view to go outside the border of its immediate parent view, and I did some logics in the touchesMoved: to reset the center or the top-most view. The effect is not good as this approach allows the view to go outside, but will move it back once it went out.

How about just creating and turning on a disable flag at the bottom views while adding the top most view to it's parent view, if you don't want the bottom views to respond to their own gesture recognisers?

Related

Is there a way to exit the current view group while using pan gesture in ios?

So I have a horizontal scroll view at the bottom of my screen which contains child views. I would like to drag a view from the bottom and snap it to a defined position on the top. But while dragging the view, it only moves about inside the scroll view. Is there any way to exit the scrollview and get the view outside it?
Layout of the app (I want to take the items from the bottom and snap them to the positions on top):
When you try moving views coordinates with drag, it will only move on its superview, i.e. your bottom scroll view.
If you wanted to drag your button outside of your scroll view then you need to have a trick here.
When user started dragging the button, hide it.
Add the same layout button on main screen on exact position.
Move the newly added button on main screen where ever you want.
Once you drop it, remove the old scroll view button.
It will look like you dragged the same button on main screen but under the hood it was a different logic.

Make a UIView receive taps but pass swipes to the underlying view

I've got a UITableView and a big "button" view in front of it. The "button" view, which has transparent areas, should be able to response to a tap. But enabling user interaction for this view blocks any scrolling touches from getting to the table view located under the "button" view.
The upper view is a UIView (not UIButton). Given how the two views work together, the upper view is essentially part of what's going on with the table view and reacts to the table view being scrolled. But scrolling is the main thing and I'd like the user to have the largest scrolling area possible.
How do I best resolve this conflict so that the table view is scrollable as usual?
I guess you could subclass your UIButton and UITableView common superview, and override its hitTest:withEvent: to verify which view is hit, something like if you are in a clear or an opaque part of the button?
As pbush25 is mentionning however, it goes more or less against Apple's recommendation.

UIGestureRecognizer Pass-Though View

How do I create a view that allows some gestures to "pass-through", basically I have 2 views the top view completely covers the other, I need the top view to handle left/right swipes and the one below has a UIScrollView that needs to respond to up/down swipes, tap and long press, so essentially pass the events down the chain.
Is this the wrong approach?

Gesture Recognizer on sub-view outside view's bounds

I'm not sure if this is possible, but I have a view that is able to be dragged around the screen via pan gestures. Once the view is selected, little grippers appear on the corners of the view that allow the user to resize the view. The problem is, those grippers go outside the bounds of the view (they still show up, because clipSubviews is off), but gesture recognizers on those grippers are not firing when selecting the part of them that is drawn outside of the view. Making the view bigger to actually hold the grippers would break a lot of already created logic that is based on the size of the view, so that is a last resort for me.
Is there any other way to get gesture recognizers to work on views that are drawn outside of their parent view?
You could try overriding hitTest:withEvent: in a UIView subclass, and return the gripper view.

How do I bringToFront a subview when I touch it?

I have a rotating carousel menu made up of 6 UIViews that were added as subViews to self.view. When you rotate the carousel, some subviews are partially behind the subview closest to the user but the problem is that the subview closest to the user may not have been added after the one behind it so when I touch it, the one behind it gets triggered.
My question is, is there a way to programmatically use bringToFront whenever a subview is touched so that it will not matter whether or not it was added first or last to the view.
When you have 2 views responding to touch events and one is in front of the other, the other one will never receive the touch.
Instead of messing around with the event chain (aka subclassing UIView and overriding hitTest…) I'd suggest you reorder the views while spinning the carousel.
The view which appears to be in front should be the topmost view in the view hierarchy.

Resources