Reputation: 170
Concept is that a user taps on an icon in a view, a copy of the icon pops up under the user's finger, and they can drag it around until they lift their finger. To do this, I desire the following
The problem is that the touchMoves (and uiPanGestureRecognizer) don't track until the user lifts his finger and puts it back down. i.e. what's happening is:
Apparently, for a UIView to recognize a drag, it seems to have to originate within the UIView. I tried (naively) to just send the touchdown event to the transparent view, but it isn't working.
Any other ideas?
many thanks...
Upvotes: 1
Views: 1119
Reputation: 2699
The trick is to use a single UIPanGestureRecognizer. Add one to your original "icon" (UIView) and use it to detect the initial touch and beginning of the pan. When the UIPanGestureRecognizer enters UIGestureRecognizerStateBegan create the view that will animate the drag. The original icon view and handler will continue to receive callbacks. You can test for UIGestureRecognizerStateChanged and translate the new moving view from within the original handler.
Upvotes: 1
Reputation: 170
As far as I can tell, you can't start a drag with any view other than the one the drag was initiated on. For those that have access, take a look at the autoscroll WWDC 2010 project. They basically start a drag on the table cell's view and then allow you to drag that TableCell off the tableview. It works well and will probably be the route I'll be taking.
Upvotes: 1