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
Post a Comment