Possible Duplicate:
how to drag an uiimage from scrollview to another uiimageview in iphone sdk
In my iPad I have a view and inside it, on the left, I have a scrollview with 10 imageViews; so I should drag and drop these images from scrollview to my big subview; how can I do it?
I did something like what you are describing once. I remember to pull it off I created a new
UIGestureRecgonizer
that I dubbedUIDownwardDragGestureRecognizer
. I think I then iterated through the scrollviews gesture recognizers to require them to wait for theUIDownwardGestureRecognizer
to fail like:Once you have this setup, you should be able to do something like:
In the UIGestureRecognizerStateBegan, once you find a UIImageView you may want to remove it from the superview (scrollview) and add it as a subview to some other container. You will need to translate the point into the new coordinate space if you do this. If you want the original image to stay in the scrollview, then make a copy of it and add that to an outside container.
To try out the above example and see it working, you may need to turn off clipping on the scrollview since the example I gave above is dragging the UIImageView from inside the scrollview (though normally you'd add it to some containing view).
On way I have seen this done is by using an overlay layer to capture the touches and pass them through. This allows you to intercept the clicks before the UIScrollView consumes them.
Here is the demo video that I looked at when trying to construct a UITableView (inside a scroll view) that could have cells dragged and dropped on to it.
Also I am not sure how applicable this is but here is a similar post I made a few days ago.
Having reviewed this issue some more I built something that allows you to drag and drop cells between UITableViews similar to the video I mentioned previously. My tutorial can be found here and the result can be seen in this YouTube video. This method uses the latest gesture features in iOS 5 and pops cells off using a long press.
Hope you can find something in here that helps.