- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
//获取触摸对象
UITouch *touch = [touches anyObject];
if (touch.tapCount == 1) {
//延迟调用
[self performSelector:@selector(signedTouch) withObject:nil afterDelay:.35];
}
if (touch.tapCount == 2) {
//取消单击事件,取消所有的单击事件
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[self doubleTouch];
}
}
//单击调用的方法
- (void)signedTouch{
self.view.backgroundColor = [UIColor brownColor];
}
//双击调用的方法
- (void)doubleTouch{
self.view.backgroundColor = [UIColor purpleColor];
}