objective c button disabling queues user touch ups -



objective c button disabling queues user touch ups -

i'm writing ap which, when press on button, button should disabled random amount of time between 0-10seconds , after that, button becomes active again. however, while button disabled, if user clicks, click seems queued waitingg button enabled , click processed. how disable , not enqueue user clicks?

-(void)buttonpressed{ nslog(@"button pressed!"); button.userinteractionenabled=false; sleep(rand()%10); proglabel.text=@"button enabled!"; button.userinteractionenabled = true; }

i'm assuming using button derives uicontrol (uibutton?). can take advantage of existing enabled property. setting property no ignore touch events. see this link info regarding uicontrol.

also, issue see in illustration sleep() function. i'm not familiar function, could blocking main thread. cautious. instead, should utilize nstimer. after each interval, might this: button.enabled = !button.enabled toggle effect.

objective-c

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -