view can't recognize gesture - ios

I got two views,view A and view B, which are on the same level, and they have overlap area. View A has a tap gesture, but in the overlap area, view A would not recognize the gesture, it's fine out of the overlap area,what would I do to make view A recognize the gesture in the overlap area?

Try
[self.view bringSubviewToFront:viewA] in viewDidLoad.

As Oleshko said, you can bring the viewA to front or you can just add viewA after viewB to the superview.

Related

Which the better way to make carousel view in swift with open - animation (expanding)?

I need to make carousel view in swift with "opening-animation".
First of all, I have created scroll view, after that have created subViews with my customView, maked my scrollView paged-enabled, and it's okay, but I need to make it expanding by swipe gesture. I added animation, but this view can't be higher than scrollView height, so I need to make this width and height (after gesture) like viewController's view height and width. And, it's the problem.
What's better way to do this?
Example screen:
BeforeGesture
Second example screen: after up-swipe gesture
I think you will need to handle it using the UIPanGestureRecognizer gesture which will give you the better control on all the different states of pan (drag began, drag ended). In your drag ended state you can handle the logic of increasing the height of scrollview and after that add the animation to show the expanded view with animation effect.
Let me know if you need any further help.

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 can I add Two GestureRecgonizer in Single View

I have a small view (View Frame Size : 100,0,20,30), i want to add two gesture recognizer one is UIPanGestureRecognizer and another one is my own custom GesuterRecognizer "CPPinGestureRecognizer".
UIPanGestureRecognizer is used for drag the view in horizontally.
Example: the dragging bounds are :(100,0 to 320, 0)
CPPinGestureRecgonizer is used for enlarge the view in vertically with the same width.
Example: (enlarge view height up to user drag the view)
Now the problem is both gesture are working together and i want to check if the view dragged horizontally means want to fail CPPinGestureRecognizer, if the user dragged vertically means want to fail UIPanGestureRecognizer.
how can i achieve this.
Thanks in advance.
Gesture recognizers can have a delegate (UIGestureRecognizerDelegate), and this protocol has 2 methods: gestureRecognizer:shouldRequireFailureOfGestureRecognizer: and gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer. You can use those to not allow one to be recognized while the other one is currently being recognized.

moving a view under finger

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?

How do I allow certain gestures to go through a superview to a view below it?

I have a view with three image views hangin' around. These image views respond to certain gestures. I want to allow a certain gesture (such as a swipe across the screen) to do an action to all of the imageviews (such as, say, delete them all).
The only way I can think of having the swipe gesture be recognized everywhere on the screen is by overlaying a clear superview that looks for swipe gestures. My problem; however, is that I don't know how to let the superview ignore all other gestures so I can still interact with the imageviews below. Is there an easier way to handle this problem?
Try adding the gesture to your view's window rather than the view:
[self.view.window addGestureRecognizer:gesture];

Resources