there 3 uibutton events available:
uitouchupinsideuitouchdownuitouchdownrepeat
my problem is:
i have button (play-pause). first time shows play button, if user taps on it, starts process. , button image changes pause , tag changes 1.
if user tap on pause button, pauses process , image changes play , tag 0.
now problem is, if user taps multiple times, not executing properly. double click on desktop mouse.
i have tried 3 above method, times, first 2 methods getting called. how avoid that.
if double tap, process should started once only.
please suggest.
edit: using touchupinside event only, there checking
if (btn.tag == 0) { // change pause button // start process btn.tag = 1; } else if (btn.tag == 1) { // change play button // stop process btn.tag = 0; } but causing issue when user taps on button. because process running on thread, takes time load , stop. meanwhile use has double tapped on button.
perhaps instead of uibutton should use uiview 2 uitapgesturerecognizers? 1 of them have numberoftapsrequired = 2, other 1 have numberoftapsrequired = 1. use method requiresgesturerecognizertofail make sure won't have them both calling target methods. can add logic want tap handling.
edit: actually, although above answer kind of workaround, fail if user taps 3 or more times. , since can't make gesture recognizer every number of taps 1 infinity, fail in cases. try this:
btn.enabled = no; if (btn.tag == 0) { // change pause button // start process btn.tag = 1; } else if (btn.tag == 1) { // change play button // stop process btn.tag = 0; } btn.enabled = yes;
Comments
Post a Comment