开发者

UIPinchGestureRecognizer not responding

开发者 https://www.devze.com 2023-03-09 16:45 出处:网络
I have a universal binary application and currently working on the iPad version of the application. The iPad is using a uitabbarcontroller and on the second tab I have 6 images and when adding a UIPin

I have a universal binary application and currently working on the iPad version of the application. The iPad is using a uitabbarcontroller and on the second tab I have 6 images and when adding a UIPinchGesture it is not responding. I have userInteractionEnabled=YES; I tried adding the image view programmatically and then adding the gesture recognizer and still nothing seems to work.

I tried setting the delegate to the view controller and implementing one of the delegate methods and didn't get any responses. Below is the code sample of what I am doing:

UIImageView *img2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img2-large.png"]];
img2.frame = CGRectMake(20, 20, 100, 100);
[img2 setUserInteractionEnabled:YES];
img2.cont开发者_JAVA百科entMode = 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");
}

I'm sure it's something silly that I'm missing. I've used this stuff before but can't for the life of me figure out what is going wrong.


Set userInteractionEnabled to YES. The default is NO. Also, in order to handle multi-touches, which is what the pinch is, multipleTouchEnabled needs to be set to YES.


What view are you placing it into? Is it a scroll view?

Also img2.multipleTouchEnabled = YES, multi touch is not enabled by default, a pinch requires multiple fingers.

(img2Pinch is correctly released)

0

精彩评论

暂无评论...
验证码 换一张
取 消