【发布时间】:2013-03-23 15:30:53
【问题描述】:
我需要从 UIScrollView 获取触摸位置。但是当我为我的滚动视图创建一个子类时:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSArray *touchesArray = [touches allObjects];
UITouch *touch = (UITouch *)[touchesArray objectAtIndex:0];
CGPoint point = [touch locationInView:self];
self.position = point;}
函数touchesBegan 并不总是被调用。
如果我快速滑动,则永远不会调用 touchesBegan,而是直接调用 scrollViewDidScroll。
我无法使用UIGesture (UITapGestureRecognizer, ... ),因为用户不会点击或滑动。
还有其他方法可以从 UIScrollView 获取位置吗?
编辑:
谢谢你:https://stackoverflow.com/a/15763450/1752843
UIScrollView 子类:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
self.position = point;
return self;
}
【问题讨论】:
标签: ios animation uiscrollview touch