So here is the catch. I have two Scroll Views, one is filled with 10 odd subviews, that are basically like playing cards (custom class views). I want to be able to drag and drop some of these views to the empty scroll bar that i have.
There are many different views in between these two scroll views. So i want to show the view being actually dragged from one view and being placed in the other scroll view. How do i achieve this.
I know i have to use touches, but if anyone can whip up a quick example, i'll be greatful. Thanks.
The first way you can use drag-and-drop on iOS is to move images from one app to another. Now, this feature works with any application that allows you to press down on an image to share it, like in Photos, Safari, Twitter and more. For this example, we'll show you how to drag-and-drop from the native Photos application. 1. Open the Photos app. 2.
You can drag-and-drop photos into Messages. The first way you can use drag-and-drop on iOS is to move images from one app to another. Now, this feature works with any application that allows you to press down on an image to share it, like in Photos, Safari, Twitter and more.
A scroll view lets people view content that’s larger than the view’s boundaries by moving the content horizontally or vertically. The scroll view itself has no appearance, but it can display a translucent scroll bar or indicator that provides additional information about the action.
Account for scroll bars in your layout. By default, scroll bars appear only when people interact with views that contain them, but people can use a setting in General settings to make them to appear all the time. Some input devices also cause scroll bars to display all the time.
Its very easy. ScrollView is like any other view so it's basically drag and drop a view from one superview to another superview.
Your hierarchy is the following: You want to drag and drop a view V from a view A to a view B. That means that when you start D&D, V is subview of A and when you finish, V is subview of B. A and B must have a common superview S.
Steps: 0/ Your touch recognizer must be on S, not on A or B.
1/ User taps on V. You remove it from A and add it to S on the same position (UIView has methods to transform position from a view to another view).
2/ User drags V to B. You change V's position in S.
3/ User drops V. If it's close enough to B, insert it to B (transforming position S->B) and animate the difference between positions. If it's still close to A, animate it back to A. If it's somewhere between A and B you can either insert it to the nearest one or let it stay there and block all other user interaction until user tap V again and drags it into A or B.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With