我有一個通用的二進制應用程序,目前正在iPad版本的應用程序上工作。 iPad使用的是uitabbarcontroller,第二個選項卡上有6張圖片,添加UIPinchGesture時沒有響應。我有userInteractionEnabled=YES;
我嘗試以編程方式添加圖像視圖,然後添加手勢識別器,但仍然沒有任何工作。UIPinchGestureRecognizer沒有響應
我試着將代理設置到視圖控制器並實現其中一個代理方法,但沒有得到任何響應。下面是我在做什麼的代碼示例:
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");
}
我敢肯定,這是愚蠢的東西我失蹤。我之前使用過這些東西,但不能爲我的生活找出錯誤的地方。
我解決我自己的問題顯然不知何故,我設法不小心把我在界面生成器視圖中啓用的用戶交互。 -1爲愚蠢。 – dbslone 2011-06-01 19:37:51