ios - touchesBegan called many times -
i have strange issue touchesbegan handler being called more necessary. if tapped uiview (uibutton) fast 2 times, touchesbegan called 3 times.
i solved issue simple time measurement still interested reason kind of behaviour?
here code (with added time-checking):
override func touchesmoved(touches: nsset, withevent event: uievent) { if let t:uitouch = touches.anyobject() as? uitouch { if !cgrectcontainspoint(cgrectmake(0, 0, self.frame.width, self.frame.height), t.locationinview(self)) { touchescancelled(touches, withevent: event) } } } override func touchesbegan(touches: nsset, withevent event: uievent) { forcanceltouch = false setupbuttongui(true) } override func touchesended(touches: nsset, withevent event: uievent) { if !forcanceltouch { if abs(lastvalidtouchesbegandate.timeintervalsincenow) > delaybetweenfasttapping { nsnotificationcenter.defaultcenter().postnotificationname(sbdcnotificationnameactionstbmakeonecommand, object: self, userinfo: ["tag":self.tag]) lastvalidtouchesbegandate = nsdate() } } setupbuttongui(false) } override func touchescancelled(touches: nsset!, withevent event: uievent!) { forcanceltouch = true setupbuttongui(false) }
well - seems issue happens when clicking/testing mouse inside ios simulator! looks ios simulator bug.
Comments
Post a Comment