使用UIButton的enabled或userInteractionEnabled
使用UIButton的enabled属性, 在点击后, 禁止UIButton的交互, 直到完成指定任务之后再将其enabled即可.
[btn addTarget:self action:@selector(nextStop:) forControlEvents:UIControlEventTouchUpInside];
- (
void)nextStop:(UIButton *
)sender {
sender.enabled =
NO;
[self btnClicked];
}
- (
void)btnClicked {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^
{
NSLog(@"btnClicked");
btn.enabled =
YES;
});
}