Let's get started in accepting drag and drop from other apps:
- Add drag and drop to our photo view from Photos apps
- Add drag and drop from filter scroller
The first thing we want to do is enable dragging for our filter items. We need to create a new extension to our PhotoFilterViewController
called PhotoFilterViewController+UIDropInteraction
. Inside this file, add the following:
import UIKit import Foundation extension PhotoFilterViewController: UIDropInteractionDelegate { }
Next, we need to add all of the methods needed to accept drop interaction. We will write this to allow dropping within the app as well as outside of the app. When you start to drag an element, Apple calls this a session. There are two primary sessions we will need to watch out for, local sessions or non-local sessions. Local sessions mean that we are dragging within our app and if that is not happening then it means that the session is coming from a different app. Let's handle this by first...