0

タッチはそれ自体の座標系でタッチ位置を取得するために self を指定できますが、別の座標系から取得するにはどうすればよいですか? 別の UIview の座標系を教えてください。

   - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [UIView beginAnimations:@"box" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationBeginsFromCurrentState:YES];
    UITouch *touch = [touches anyObject];
    box.center = [touch locationInView:self];
    [UIView commitAnimations];
}

「自己」がある別の UIview の名前でできますか?

4

1 に答える 1

5

「このメソッドは、指定されたビューの座標系で UITouch オブジェクトの現在の位置を返します」ので、別のビューを渡すことができます。2 つのビューが重なっているサンプル プロジェクトを試して、両方のビューへの 2 つの呼び出しの結果を NSLog に記録できることを確認してください。

于 2009-07-10T17:47:42.030 に答える