如何在scrollview下进行imageView触摸事件?

时间:2012-05-21 08:11:09

标签: objective-c

我在- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event中使用了imageView触摸方法,但我在imageView下采用scrollview这就是为什么触摸事件无法执行,因为它直接采用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;
    }


}

imagedisplay我的imageView对象但是在不工作的触摸事件中我在scrollview中工作了所拍摄的imageView所以给出任何解决方案和源代码相关的触摸,适用于scrollview和imageView

1 个答案:

答案 0 :(得分:0)

使用以下代码创建imageView -

imageView.userInteractionEnabled = YES;

默认情况下为NO