2012-02-19 86 views
0

我用我的应用程序的代码来识别特定的UIView触摸和拖拽,的touchesBegan和touchesMoved卡

现在我有一个问题,如果我使触摸和直接使一个拖动touchesMoved只有3-称为4次,然后停止,然后调用touchesCancelled,但是如果我触摸屏幕等待一秒钟,然后每次手指移动时拖动它拨打touchesMoved

编辑

Ijust测试了iPhone 4S的,并与该设备它的工作完美,在ipod4它仍然有问题。这两个设备都是5.01。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 
      NSArray* touchArray = [touches allObjects]; 

     UITouch* touch = [touchArray objectAtIndex:0]; 
     CGPoint point = [touch locationInView:self.view]; 
     UIView *tmp = [self.view hitTest:point withEvent:event]; 

     if (tmp == volumeViewBackground) { 
      //do something 
     }else { 
      NSLog(@"err"); 
     } 

    } 

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 
    NSArray* touchArray = [touches allObjects]; 

    UITouch* touch = [touchArray objectAtIndex:0]; 
    CGPoint point = [touch locationInView:self.view]; 
    UIView *tmp = [self.view hitTest:point withEvent:event]; 

    if (tmp == volumeViewBackground) { 
     //do something 
    }else { 
     NSLog(@"err"); 
    } 
} 

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ 
    NSLog(@"error"); 
} 
+0

这里没有足够的代码来显示导致问题的原因。 – colbadhombre 2012-02-19 15:44:48

回答

0

根据UIResponder Class Reference尝试调用super

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 

     [super touchesBegan: touches withEvent: event]; 

     NSArray* touchArray = [touches allObjects]; 

     UITouch* touch = [touchArray objectAtIndex:0]; 
     CGPoint point = [touch locationInView:self.view]; 
     UIView *tmp = [self.view hitTest:point withEvent:event]; 

     if (tmp == volumeViewBackground) { 
      //do something 
     }else { 
      NSLog(@"err"); 
     } 

    } 

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 

    [super touchesMoved: touches withEvent: event]; 

    NSArray* touchArray = [touches allObjects]; 

    UITouch* touch = [touchArray objectAtIndex:0]; 
    CGPoint point = [touch locationInView:self.view]; 
    UIView *tmp = [self.view hitTest:point withEvent:event]; 

    if (tmp == volumeViewBackground) { 
     //do something 
    }else { 
     NSLog(@"err"); 
    } 
} 

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ 

    [super touchesCancelled: touches withEvent: event]; 

    NSLog(@"error"); 
} 
相关问题