1. The timer can be used for delay.
-(void) Timeenough
{
UIButton *btn= (uibutton*) [Self.view viewwithtag:33];
Btn.selected=no;
[Timer invalidate];
Timer=nil;
}
-(void) Btndone: (uibutton*) btn
{
if (btn.selected) return;
Btn.selected=yes;
[Self performselector: @selector (Timeenough) Withobject:nil afterdelay:3.0]; Use delay to limit.
To do something.
}
2. Cancel the task before the time is executed. personally think this method is more useful.
-(void) todosomething: (ID) sender
{
Do the buttons here to do the things you want to do.
}
-(void) starbuttonclicked: (ID) sender
{
The task is canceled before the time of execution.
[Self- class] cancelpreviousperformrequestswithtarget:self selector:@selector (todosomething:) object:sender];
[self performselector:@selector (todosomething:) Withobject:sender afterdelay:0.2f];
}
Avoid multiple responses caused by button quick clicks