2

私のアプリには、tapGesture、panGesture、rotationGesture、pinchGestureがあります。tapGestureはすべてのジェスチャの開始点であり、特にどのサブビューが選択されているかを示します。

ImagePickerを処理するボタンを入力した後も、サブビューが選択されているため、ジェスチャを処理しています。

私の質問:ジェスチャーの処理を停止するステートメントはありますか?

編集

私はgestureRecognizerを必要としないので、それらを非アクティブにします。

panRecognizer.enabled = NO;
pinchRecognizer.enabled = NO;
rotationRecognizer.enabled = NO;

したがって、それらが必要な場合は、tapRecognizerを処理しているときにそれらを機能させたいのですが、ここでは、レコグナイザーは非アクティブからアクティブに移動しません。

[panRecognizer isEnabled];
pinchRecognizer.enabled = YES;
rotationRecognizer.enabled = YES;

編集

私のビューはViewControllerであり、サブビューはimageViewにあります。
レコグナイザーはself.imageViewに割り当てられます。
最初の方法ではレコグナイザーを無効にし、2番目の方法ではレコグナイザーを有効にします

- (IBAction)photo: (id) sender {

    panRecognizer.enabled = NO;
    pinchRecognizer.enabled = NO;
    rotationRecognizer.enabled = NO;

    UIImagePickerController* picker = [[UIImagePickerController alloc]init];
    picker.delegate = self;
    picker.allowsEditing = NO;

    @try {

        picker.sourceType=UIImagePickerControllerSourceTypeCamera;
        [self presentModalViewController:picker animated:YES];
    }
    @catch (NSException * e) {

        UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error" message:@"Camera is not available" 
                                                        delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
        [alert show];
    }
    [picker release];
}

- (IBAction)oneTap: (UIGestureRecognizer*)gestureRecognizer { 
    NSLog(@"oneTap");
    float differenz = 2000;
    [panRecognizer isEnabled];
    pinchRecognizer.enabled = YES;
    rotationRecognizer.enabled = YES;

    for (UIView* const subview in array) {  
        subview.opaque = YES;
        CGPoint const point = [gestureRecognizer locationInView:self.imageView];

            float zwischenS = sqrt(powf(point.x - subview.frame.origin.x,2)) + sqrt(powf(point.y - subview.frame.origin.y,2));


            if (differenz > zwischenS ) {

                differenz = sqrt(powf(point.x - subview.frame.origin.x,2)) + sqrt(powf(point.y - subview.frame.origin.y,2));
                newView.layer.borderColor = [[UIColor clearColor]CGColor];
                newView = subview;

                subview.layer.borderColor = [[UIColor whiteColor]CGColor];
                subview.layer.borderWidth = 3.0f;
                [imageView bringSubviewToFront: subview]; 
            } 
    }
} 

私の間違いは何ですか?

前もって感謝します

4

2 に答える 2

4

財産[UIGestureRecognizer enabled]

于 2012-04-26T07:59:45.933 に答える
2
//YOU CREATE GESTURES LIKE THIS
 UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]
                                      initWithTarget:self  action:@selector(handlePanGesture:)];

//YOU ADD THEM LIKE THIS
     [self.view addGestureRecognizer:panGesture];

//AND YOU REMOVE THEM LIKE THIS
     [self.view removeGestureRecognizer:panGesture];

どのようにコーディングしているのかわかりませんが、これでアイデアが得られることを願っています

于 2012-04-26T08:49:35.373 に答える