- 设置点击间隔时间
- (void)viewEvent{
static NSTimeInterval time = 0.0;
NSTimeInterval currentTime = [NSDate date].timeIntervalSince1970;
if (currentTime - time < 2.0) {
NSLog(@"%s", __func__);
return;
}
time = currentTime;
//事件处理
}
- 点击后禁止交互事件
- (void)viewEvent: (UIView *)view{
view.userInteractionEnabled = NO;
[self performSelector:@selector(viewStatusChange:) withObject:view afterDelay:2.0];
//事件处理
}
- (void)viewStatusChange: (UIView *)view{
view.userInteractionEnabled = YES;
}
- 点击后覆盖前一事件
- (void)viewUserInterface: (UIView *)view{
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(viewEvent:) object:view];
[self performSelector:@selector(viewEvent:) withObject:view afterDelay:.2];
}
- (void)viewEvent: (UIView *)view{
//事件处理
}
网友评论