我有一个通用的二进制应用程序,目前正在开发该应用程序的iPad版本。iPad使用using控制器,在第二个选项卡上我有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");
}我肯定我漏掉了一些愚蠢的东西。我以前用过这个东西,但我的一生都不能弄清楚哪里出了问题。
发布于 2011-06-02 02:33:27
将userInteractionEnabled设置为YES。默认值为NO。此外,为了处理多点触摸,需要将multipleTouchEnabled设置为YES。
发布于 2011-06-02 04:57:46
您要将其放置到什么视图中?它是滚动视图吗?
此外,img2.multipleTouchEnabled = YES默认情况下不启用多点触摸,一次握手需要多个手指。
(img2Pinch已正确发布)
https://stackoverflow.com/questions/6205918
复制相似问题