我正在为 iPad 开发 iOS 应用程序。我使用 I 代码来检测用户何时触摸对象,但现在我想使用相同的代码来检测用户何时不触摸对象。这是代码:
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
if (CGRectContainsPoint(ribbon.frame, location) || CGRectContainsPoint(inferior.frame, location) || CGRectContainsPoint(superior.frame, location) & (pujat==YES)){
pujat=NO;
[UIView animateWithDuration:0.25 animations:^{
superior.frame = CGRectMake(0, 710, 1024,500);
ribbon.frame = CGRectMake(480, 685, 70,70);
inferior.frame = CGRectMake(0, 750, 1024,500);}];
[self.view bringSubviewToFront:inferior];
}
}
那么如何检测用户何时触摸屏幕而不是某个对象呢?