我有一个自定义的滚动视图,实现了以下方法:
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
//if not dragging send it on up the chain
if(!self.dragging){
[self.nextResponder touchesEnded:touches withEvent:event];
}else {
[super touchesEnded:touches withEvent:event];
}
}
在我的视图控制器中,我有以下方法:
-(void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
NSLog(@"TOUCH");
//---get all touches on the screen---
NSSet *allTouches = [event allTouches];
//---compare the number of touches on the screen---
switch ([allTouches count])
{
//---single touch---
case 1: {
//---get info of the touch---
UITouch *touch = [[allTouches allObjects] objectAtIndex:0];
//---compare the touches---
switch ([touch tapCount])
{
//---single tap---
case 1: {
NSLog(@"Single");
[self mySingleTapMethod];
} break;
//---double tap---
case 2: {
[self myDoubleTapMethod];
} break;
}
} break;
}
}
在 iOS 4 下,这完美运行,滚动视图上的触摸被识别,并且 touchesEnded 在我的视图控制器中被调用,一切正常。然而,在 iOS 5x 下,touchesEnded 永远不会被触发。有谁知道到底发生了什么/错了?