Ignore UIButton's touch event in a long task time
I want ignore all touch event of a button while a long task is running.
- (void)buttonAction{
NSLog(@"click!");
button.enabled = NO;
[self longTask];
}
- (void)longTask{
NSLog(@"task begin!");
sleep(5);
NSLog(@"task finished!");
button.enabled = YES;
}
During the longTask time, I click the button again, it really nothing
happens. BUT, when the longTask is finished, it automatically respond to
the click events and execute the longTask again! How many times I clicked
when the button's enabled value is 'NO', the longTask will perform how
many times.
2013-08-20 09:24:49.478 AppName[2518:c07] click!
2013-08-20 09:24:49.479 AppName[2518:c07] task begin!
2013-08-20 09:24:54.481 AppName[2518:c07] task finished!
2013-08-20 09:24:54.482 AppName[2518:c07] click!
2013-08-20 09:24:54.482 AppName[2518:c07] task begin!
2013-08-20 09:24:59.484 AppName[2518:c07] task finished!
I tried to set serInteractionEnabled and got the same result.
How can make it ignore all touch event when a long task is running and
never performs the task? In other words, only executes the longTask when
the button's clicked at it's enabled value is 'YES'?
Thanks any help!
No comments:
Post a Comment