2012-05-12 5 views
-2

私はiPhoneの初心者です。タッチイベントに取り組んでいます。私はこのコードを入れているが、そのタッチでは画像ビューでは実行されません私はまた、その理由は、タッチイベントを適用していないので、imageViewでscrollviewを使用している。画像ビューでタッチイベントを適用する方法

私のコードは

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    // get touch event 
    UITouch *touch = [[event allTouches] anyObject]; 
    CGPoint touchLocation = [touch locationInView:self.view]; 

    if ([touch view] == imagedisplay) { 
     // move the image view 
     imagedisplay.center = touchLocation; 
    } 

} 

であるが、その中でタッチイベントを実行しないと、いずれの提案に任意のソースコードを与える

+0

? 適切な英語を使用して正しく説明してください – MCKapur

答えて

0

あなたはUIGestureRecognizerを使用することができます。その後

UITapGestureRecognizer* Tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewTapDetected:)]; 
[Tap setDelegate:self]; 
[Tap setNumberOfTapsRequired:1]; 
[ImageView addGestureRecognizer:Tap]; 

あなたの関数では、状態関数を使用して、現在のタップの状態を決定することができる:あなたが何を言っている

-(void)imageViewTapDetected:(UItapGestureRecognizer*)Tap{ 

    switch ([Tap state]) { 
     case UIGestureRecognizerStatePossible: 

      break; 
     case UIGestureRecognizerStateBegan: 


      break; 
     case UIGestureRecognizerStateChanged: 


      break; 
     case UIGestureRecognizerStateEnded: 


      break; 
     default: 

      break; 
    } 
} 
関連する問題