我們先定義一個全局變量控制多少次內是不頻繁的
在按鈕執行方法中:
- (void)addCareBtnClick:(id)sender{
touchCount++;
if(touchCount<5) {
[self careClick];//不是頻繁操作執行對應點擊事件
} else {
[MBProgressHUD showErrorWithText:@"您操作太頻繁了"];
[self performSelector:@selector(timeSetting) withObject:nil afterDelay:4.0];//4秒后點擊次數清零
}
}
-(void)timeSetting{
touchCount=0;
}