2011-12-30 4 views
0

ビューにサブビューを追加しました。触れたとき、それはタッチイベントをアニメーション化されたとき、私はあなたの風船のクラスにして」の「touchesBegan」メソッドを実装する必要があります...ここで コード..ですサブビューを見つけることです、iphoneでアニメーション化しているときにサブビューがタッチされたときを見つけますか?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
     UITouch *touch = [touches anyObject]; 
     if ([touch self]) { 
      NSLog(@"View Touched"); 
     } 
     if ([[touch view] isKindOfClass:[Baloon class]]) { 
      NSLog(@"Baloon Touched"); 
     } 
    } 

答えて

0

それを見つけていますtouchesMove "メソッドは、新しい位置をバルーンに設定しました!

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


    NSSet *allTouches = [event allTouches]; 
    switch ([allTouches count]) { 
    case 1: { 
     UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; 

     [self setCenter:[touch locationInView:self.superview]]; 
    } 
     break; 
    default: 
     break; 
    } 
} 
関連する問題