IOS drag and drop between scroll views

So, here is the catch. I have two types of scrolling, one of which is filled with 10 odd subzones, which are mostly similar to game cards (custom class representations). I want to be able to drag some of these views onto the empty scrollbar that I have.

There are many different points of view between these two scroll lists. So I want to show that the view is actually dragged from one view and placed in another scroll view. How do I achieve this.

I know that I need to use touch, but if anyone can crack a quick example, I will be generous. Thanks.

+7
source share
1 answer

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.

+7
source

All Articles