Dragging and Dropping Image - how to drop correctly

Discussion in 'iOS Programming' started by theprizerevealed, Mar 19, 2017.

  1. theprizerevealed macrumors member

    Feb 26, 2016
    I wish to drag and drop an image to a specific location the screen. I have a tutorial that seems to explain how to do the dragging:

    But it isn't clear to me how to drop the image into another location and cause it to lock into place and confirm that it is dropped in the proper location. Is that done manually in the code by specifying the numbers of the screen location? That seems very cumbersome.

    I investigated the tableview drage and drop features but that doesn't seem suited to my needs. Any suggestions? thanks
  2. AxoNeuron macrumors 65816


    Apr 22, 2012
    The Left Coast
    Drag and drop isn't a fundamental concept of iOS, there isn't a super simple way to do it.

    I'd suggest using a UIPanGestureRecognizer. Use Core Animation to animate the dragging of the image to wherever the user's finger is.

    This isn't super simple, you need a pretty good grasp on a lot of concepts (auto layout, how frames work, animation, gesture recognizer, image views). It's not for new programmers, that's for sure. It took me like five months to really get those basics down, and took probably a full year to do it well. Then again, iOS/ObjC was my first programming language, so if you have prior experience you may find it easier.

Share This Page