我正在使用苹果示例代码_TapToZoom。当用户点击时,他们使用UIGestureRecognizers处理单个双击,以缩放滚动视图(带图像)。现在,我希望在用户缩放图像scrollview时实现相同的功能。我正在浏览这么多链接,但没有帮助。请帮我解决这个问题....
答案 0 :(得分:1)
像这样添加手势识别器:
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(<your gesture handling callback>:)];
[self.view addGestureRecognizer:pinch];
[pinch release];
此条件将检查手势识别器是否为UIPinhcgestureRecognizer,并且内部条件检查用户是否已挤压或缩放:
if ([sender isKindOfClass:[UIPinchGestureRecognizer class]]) {
[gesture setString:kPinchGesture];
if (((UIGestureRecognizer*)sender).state == UIGestureRecognizerStateEnded) {
if (((UIPinchGestureRecognizer*)sender).scale < 1) {
NSLog(@"Pinched");
}
else {
NSLog(@"Zoomed");
}
}