Objective c 如何在图像视图中应用触摸事件

Objective c 如何在图像视图中应用触摸事件,objective-c,Objective C,我是iPhone的初学者,我一直致力于触摸事件。我已经把这个代码,但在触摸是不执行在图像视图中,我也使用了scrollview对图像视图,以便在这方面的原因不适用触摸事件 我的代码是 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // get touch event UITouch *touch = [[event allTouches] anyObject]; CGPoint to

我是iPhone的初学者,我一直致力于触摸事件。我已经把这个代码,但在触摸是不执行在图像视图中,我也使用了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;
    }

}

但如果不执行触摸事件,请给出任何建议任何源代码,您可以使用UIgestureRecognitor

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;
    }
}

你在说什么?请使用正确的英语并正确解释