2012-02-19 30 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"); 
} 
相關問題