How to get event touch move of UIView when move finger from outside view - ios

I have a UIView custom. In this UIView custom, I have a small UIImageView. When I move finger through it, it will move with my finger. To do that, I use UIPanGestureRecognizer (add this gesture to UIImageView). But when I move finger with begining point not in UIImageView, it will not handle this event.
So, my question is "How to get event touch move of UIView when move finger from outside view ?"
Thanks.

Best approach is create a uiview with necessary size(which is larger than uiimageview). Place the uiimageview inside it. Add gesture recognizer to uiview instead of uiimageview. In the delegate method of geature, move the image view.

There is a "Touch Drag Enter" Event which might be what you are looking for.

Related

Drag Drop UIImageView into subView - Swift 3

I'm newbie to Swift and trying to drag a UIImageView into UiView, I have three UIViews i have to drag the UIImageView into any three UIViews , not anywhere.
I have tried touchesBegan, touchesEnded method, but drag drop is not on inside this any of 3 UIViews.
Please anyone give me skeleton to drop the UIImageView to anyone of three UIViews,
UIImageView and all UIViews probably share the same superView, if you want to put UIImageView inside of UIView you need to move it. I mean you need to remove it from superView and add it to the view beneath it (if they intersect)
Here's what you're gonna do:
When User touches (pans) the UIImageView, move it to superView (If It's already there, it's ok, if It's in one of UIViews, you need to remove it from them, and add it to superView)
When user touch has ended, UIGestureRecognizer will also inform you about it, at that moment check if there's any UIViews beneath your UIImageView or not, if not do nothing else remove it from superView and add the view beneath it.
There's also a WWDC video which covers advanced touch handling techniques.

Movable UIButtons

Scenario:
There is an UIView as a sub view of a UIScrollView and there is a UIImageView as a sub view of the UIView.
Requirement:
When the user touches on the UIImageView I want to add a UIButton as a sub view at that touch point. Any amount of UIButtons could be added (Within the UIImageView frame). These UIButtons should also be movable inside the UIImageView frame.
What I have done
I have sub classed the UIView and I'm detecting touches using methods touchesBegan, touchesMoved, touchesEnded and adding UIButtons. UIButtons are added with UIGestureRecognizers with a method implemented to the pan gesture.
Problem
When I add more than one button the earlier ones becomes non-movable and doesn't even recognise touch up inside.
Thank you all for the help. I ended up doing this https://github.com/Tulakshana/TTaggableView
You should read about Gesture Recognizers:
https://developer.apple.com/library/ios/documentation/uikit/reference/UIGestureRecognizer_Class/Reference/Reference.html
http://www.raywenderlich.com/6567/uigesturerecognizer-tutorial-in-ios-5-pinches-pans-and-more
Start with UITapGestureRecognizer for showing UIButtons.

touchesBegan and ended in collection view

I am trying to have a view with a frame on the cell in a UICollectionView from the second a user taps.
The function I want it to have is:
Appear when touches begins in a cell, touchesBegan?
If the touch is a single tap, tell me so I can handle
If the touch is a long press, tell me so I can handle
If user moves finger while down, move frame.
Right now, i'm adding the frame as an image in a UIImageView in a UICollectionViewCell on a gesture recogniser i've added for longpress. Single tap is detected with standard UICollectionView delegate methods.
Any ideas on how I could accomplish this? I don't know about any methods for cancling touchesBegan/Ended on single tap etc...
Maybe this will help
UIResponder touchesBegan:withEvent:, touchesMoved:withEvent:, touchesEnded:withEvent:

send touch events to another view

I have a UIView ontop of a mapview. Currently the UIView is handling the touchesBegan, touchesMoved and touchesEnded. I need to make it so that the UIView is able to send touch events to the mapView. I have been looking at gesturerecognizers, but so far have had no luck. Has this been done before?, and if so, how can i do this?
my view heiarchy in storyboard
view
mapView
UIView
a little more clarification.
My UIView is used to draw from touch inputs. I have a button that enables and disables the drawing, but the touch events are still bieng handled in the UIView. I want to make it so that when i disable drawing by pressing my button. The user interacts with the mapview instead of the UIView.
I have tried setting userInteractionEnabled = NO in the UIView, but then i can't regain control in that view when the draw button is pressed again.

How do I pass delayed scroll gestures from a UIButton inside of a UIScrollView?

I have a UIScrollView that contains several UIButtons. Each button is wired up to take an action when the user inputs a touch up event, so they are able to place their finger on the button and it will not be selected until it is raised. Currently, if I made a swipe gesture to scroll the UIScrollView quickly, then the scroll view moves as expected even if the gesture happens directly over a UIButton. HOWEVER, if I hold my finger down too long on a UIButton (about 1 second), the UIScrollView will no longer recognize the gesture and will not be able to scroll until the finger is lifted up.
I am wondering if their is a way to always have the UIScrollView recognize the scroll gesture? Note that this is not an issue if I touch the UiScrollView in a location without a UIButton - it then scrolls as expected.
It may worth a try to let your UIButton respond to UIControlEventTouchDown (maybe with an empty action). I'm not sure if this will work, but conceptually I think it should let the UIButton capture the touch immediately.
(Also make sure you don't enable delaysContentTouches on your scrollview.)
I found the answer to this here: UIScrollview with UIButtons - how to recreate springboard?
Essentially, I had to extend UIScrollView and override touchesShouldCancelInContentView, having it always return YES.

Resources