ios - Xcode6 - Swift: How to detect which object is touched and move/drag/drop? -


i'm trying have more 1 off these types: @iboutlet weak var objecttomove1: uiimageview

and want able detect when 1 of them touched... if held down on object , moving finger, want object follow.. when dropped, want see if interfere object of same type...

i found example:

override func touchesmoved(touches: nsset, withevent event: uievent) {     var touch : uitouch! = touches.anyobject() uitouch     location = touch.locationinview(self.view)           objecttomove1.center = location } 

this works, specific object (here: "objecttomove1")... , moves position first put finger (don't matter put finger)...

so, how can tweek able detect if i'm touching object , follow finger + detect if interfere (collide) object when lifting finger?

thanx! kjetil

use uitouchgesturerecognizer. can create general 1 uses delegate call handle touch. can add views create programatically or in viewdidload type methop can attach there.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -