0

I need have a view where users can draw multiple rectangles. Now I need to be able to move those rectangles using a Pan gesture. The problem I am having is that I can move any single rectangle with the Pan gesture recognizer with no problem. Now when I use 2 fingers to Pan 2 rectangles to move simultaneously it doesn't work.

Seem to me that the problem is the target/action that I specified for the pan gesture gets fired only once.

My view adopts the UIGestureRecognizerDelegate and has defined this delegate method:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{   
    return YES;
}

Thanks in advance!

4

1 に答える 1

1

メソッドを作成して、作成された各長方形ビューにジェスチャ認識エンジンを個別に追加します。

このような

- (void)addGestureRecognizersToPiece:(UIView *)piece
{
  // Add the gesture recognizer to the piece here
}

ループしてすべてのピースにジェスチャ認識エンジンを同時に追加するか、各長方形を作成している間に、長方形を作成した後にこのメソッドを起動し、それをピース パラメータとしてこの関数に渡すことができます。

それは役立つはずです。

于 2011-10-20T06:24:00.473 に答える