2011-08-05 3 views
0

私は画像を移動する必要があるアプリケーションがあります。マウスが移動した画像にマウスで触れると問題が発生しますが、メインビューに触れると全体のビューも動きます。TouchesMovedでUIViewを無効にする

私はview.userInteractionEnabled = NOを試しました。

ですが、1回の移動後に全景がフリーズします。

私は静的であることを望む(移動しない)

ヘルプ!!!ここ

は、コードあなたの親ビューもUIImageViewではないと仮定し

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
    UITouch *touch = [[event allTouches] anyObject]; 

    UIImageView *imgPimples = [[UIImageView alloc]init]; 
    imgPimples = (UIImageView*)[touch view]; 
    CGPoint touchLocation = [touch locationInView:imgPimples]; 
    imgPimples.center = touchLocation; 
} 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
} 
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
} 
+0

「touchesEnded」「touchesMoved」コードと「touchesBegan」コードを投稿できますか? – Hisenberg

+0

あなたは本当にあなたがそれを解放していない場合、特にtouchesMovedでallocをやりたがっていません! – ader

+0

実際、私はボタンをクリックするたびに同じ画像を追加しています。 –

答えて

0

タッチされたクラスが種類UIImageViewかどうかを確認してください。私はそれがあなたの目的を果たすだろうと思い

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

UITouch *touch = [[event allTouches] anyObject]; 
    if ([[touch view] isKindOfClass:[UIImageView class]]) { 
     UIImageView *imgPimple; 
     imgPimple = (UIImageView *)[touch view]; 
     CGPoint touchLocation = [touch locationInView:imgPimple]; 
     imgPimple.center = touchLocation; 
    } 

}

+0

はい私は同じことをやった! –

0
if ([touch.view isKindOfClass:[UIImageView class]]){ 
imgPimples.center = touchLocation; 
} 

です。

+0

ありがとう、私はそれを修正します。 –

関連する問題