开发者

How to implement exchanging items' locations by drag and drop

I am working on a mac application but have ran into a road block. I am trying to create 2 images and make it so they can be dragged and dropped to swap their locations. I am completely lost here so a thorough explanation would be greatly 开发者_开发知识库appreciated! I'm not new to programing but Ive only been working with xCode and objective c for a few months. Thanks in Advance!


The similar way is true for your images. The difference is that you replacing two objects at the same time, so you should create two temporary variables.

  1. create some CGRect variable named img1rect to store a rectangle of 1st image and img2rect variable (I think you've got for what)
  2. Drag 1st image onto the 2nd, then place. If dragg'n'drop is successfull (e.g. you could check whether touch coordinate is located on 2nd mage) set img1rect as frame for the 2nd image and img2rect as frame for the 1st.

If the matter of question is drag'n'drop handling you could find plenty of information using search. For example, chck this out: Basic Drag and Drop in iOS

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜