ios - Multiple touches on UIButton with Swift? -
i trying count number of fingers touches button @ same time.
i tap 1 time: +1, tap 2 fingers: +2, tap 3 fingers: +3 , on...
what have:
var count = 0; @ibaction func ontap(sender: uibutton) { count++; }
the "ontap" function however, fires 1 time if touch button multiple fingers.
how track number of fingers button has been touched with?
import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var bigbutton: uibutton! override func viewdidload() { super.viewdidload() let onefingertap = uitapgesturerecognizer(target: self, action:"onefingertapdetected:") onefingertap.numberoftouchesrequired = 1 let twofingertap = uitapgesturerecognizer(target: self, action:"twofingertapdetected:") twofingertap.numberoftouchesrequired = 2 let threefingertap = uitapgesturerecognizer(target: self, action:"threefingertapdetected:") threefingertap.numberoftouchesrequired = 3 bigbutton.addgesturerecognizer(onefingertap) bigbutton.addgesturerecognizer(twofingertap) bigbutton.addgesturerecognizer(threefingertap) } override func didreceivememorywarning() { super.didreceivememorywarning() } func onefingertapdetected(sender:uitapgesturerecognizer) { println("one") } func twofingertapdetected(sender:uitapgesturerecognizer) { println("two") } func threefingertapdetected(sender:uitapgesturerecognizer) { println("three") } }
Comments
Post a Comment