如何向 UIScrollView 的 subview 添加拖动事件?结构如下:
-UIView
-UIScrollView
-UIView
-UIView
...
我试着从以下开始:
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *aTouch = [touches anyObject];
CGPoint location = [aTouch locationInView:self.superview.superview];
[UIView beginAnimations:@"Dragging A DraggableView" context:nil];
self.frame = CGRectMake(location.x, location.y,
self.frame.size.width, self.frame.size.height);
[UIView commitAnimations];
但是没有任何反应!帮助将不胜感激。 谢谢
最佳答案
为了防止有人像我一样发现这个问题,我通过向 ScrollView 中的 subview 添加手势识别器解决了这个问题。手势识别器将自行处理触摸事件。
关于objective-c - UIScrollView 的 subview 中的拖动事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7365520/