2
我有一個自定義的滾動視圖以實現以下方法:TouchesEnded不是在iOS5的工作,做工精細的iOS4的
- (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下,這個功能完美,觸動scrollview被識別,並且touchesEnded在我的視圖控制器中被調用,並且與世界一切都是正確的。然而,在iOS 5x下,touchesEnded永遠不會被解僱。有誰知道這是什麼事?/錯?
在iOS 5中的問題似乎涉及到叫出了滾動型從未到達ViewController中的touchesEnded。scrollView中的touchesEnded確實被觸發。 – user282172 2012-07-07 17:58:42