Dragging a subview of a view to its parent view
I've been searching for the solution for hours. While I can find similar questions, I didn't get the answer. Please help me with this. Here is the situation.
I'm developing an iPad application. I have a custom UIControl (subclass of UIControl) object C within a UIScrollView B which is within the root view A. So the parent-child relationship is like this: A -> B -> C. What I want to do is to drag my custom UIControl C to the root view A. Here 开发者_如何转开发is what I did.
Because C is a UIControl, I registered UIControlEventTouchDown and UIControlEventTouchDragInside events to it to track the finger movement. However, the registered methods got triggered only inside C's frame. When my finger touches inside the frame, it works. When I drag it outside C's frame to B and then A, I lost the finger movement event. I wonder what's the correct way to do this.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIControl_Class/Reference/Reference.html
The UIControlEventTouchDragInside will only notice a drag event inside the bounds of the View. You need to also add a UIControlEventTouchDragOutside to the C View, or you can be notified of all touches and find out where the touch is on the X,Y and see if the coordinate of the touch is inside your C View and then do something with it when the touches end and during the touches dragged.
精彩评论