It is very easy. ScrollView is just like any other view, so it basically drags a view from one supervisor to another supervisor.
Your hierarchy is this: you want to drag view V from view A to view B. This means that when D & D starts, V is sub-item A, and when you are done, V is sub-item B. A and B should have a common view of S.
Steps: 0 / Your touch recognizer should be on S, not on A or B.
1 / Disables the user on V. You delete him from A and add him to S at the same position (UIView has methods for converting a position from a view to another view).
2 / User drags V to B. You change the position of V to S.
3 / The user falls V. If he is close enough to B, insert him into B (transforming position S-> B) and change the difference between the positions. If it is still close to A, animate it to A. If it is somewhere between A and B, you can either insert it in the nearest one or leave it there and block all other user interactions until the user touches V yet times and drag it in or B.
Sulthan
source share