UIPinchGestureRecognizer没有被调用

时间:2012-01-12 20:57:23

标签: iphone objective-c ios ipad

我不确定为什么在执行此操作时不会调用目标:

 UIImage * imgSrc = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageSource]]];
            UIImageView * imgView = [[[UIImageView alloc] initWithImage:imgSrc] retain];

            UIPinchGestureRecognizer * pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(resizeImage:)];
            [imgView addGestureRecognizer:pinchGestureRecognizer]; 
            [pinchGestureRecognizer release];

- (IBAction)resizeImage:(UIPinchGestureRecognizer *)sender
{
   //not getting here
}

调用大小调整图像不会被调用。图像显示得很好

1 个答案:

答案 0 :(得分:1)

您需要设置imgView.userInteractionEnabled = YES。它默认为“NO”。