我有一个通用二进制应用程序,目前正在开发iPad版本的应用程序。iPad使用uitabbarcontroller,在第二个选项卡上有6张图片,添加UIPinchGesture时没有反应。我已经设置了
userInteractionEnabled=YES;
。我尝试通过编程方式添加图像视图,然后添加手势识别器,但仍然无法工作。我尝试将委托设置为视图控制器并实现其中一个委托方法,但没有得到任何响应。以下是我所做的代码示例:UIImageView *img2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img2-large.png"]];
img2.frame = CGRectMake(20, 20, 100, 100);
[img2 setUserInteractionEnabled:YES];
img2.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubview:img2];
UIPinchGestureRecognizer *img2Pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(img2Pinch:)];
[img2 addGestureRecognizer:img2Pinch];
[img2Pinch release];
- (void)img2Pinch:(UIPinchGestureRecognizer *)sender {
NSLog(@"HERE");
}
我相信我错过了一些愚蠢的东西。我以前用过这个东西,但是现在我想不出哪里出了问题。