我认为无法使用UIScrollView的正常缩放行为来实现这一点,因此我正在尝试自己编写代码。(我可以让它完成其工作,然后在-scrollViewDidEndZooming:withView:atScale:被调用时重新绘制我的内容,但这并不美观。)
目前,我正在子类化UIScrollView,并尝试在屏幕上有两个手指时进行自己的缩放。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if ([touches count] != 2) {
[super touchesMoved:touches withEvent:event];
} else {
// do my own stuff
}
}
我认为通过重写touchesBegan:withEvent:, touchesMoved:withEvent:, touchesEnded:withEvent:和touchesCancelled:withEvent:方法应该可以解决问题,但事实并非如此。
之前的失败尝试是在滚动视图上放置一个透明视图,并将我不感兴趣的触摸事件发送到滚动视图中。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if ([touches count] != 2) {
[self.theScrollView touchesMoved:touches withEvent:event];
} else {
// do my own stuff
}
}
任何帮助都将不胜感激。
谢谢, Thomas