1

I am using ImageAnalysisInteraction to allow the user to press and hold part of image to lift it and drag it somewhere else. I got the drop part working, but how do I detect when they started dragging?

The delegate and interaction function below help me find out when the user pressed and held, but not when they started dragging the image. This is a new iOS 17 API.

class ImageAnalysisViewController: UIViewController, ImageAnalysisInteractionDelegate {
    func interaction(_ interaction: ImageAnalysisInteraction, shouldBeginAt point: CGPoint, for interactionType: ImageAnalysisInteraction.InteractionTypes) -> Bool {
        print("lifted subject")
        return true
    }

    [...]
    
    let interaction = ImageAnalysisInteraction()
    var imageView: UIImageView?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        guard let imageView = imageView else { return }
        
        view.addSubview(imageView)
        imageView.addInteraction(interaction)
        interaction.delegate = self
    }
}
Streetlamp
  • 1,537
  • 2
  • 15
  • 27

0 Answers0