【发布时间】:2010-04-06 19:55:25
【问题描述】:
我在 UIScrollView 中有一个视图,当用户按下某个区域时,它会加载一个额外的子视图。当这个额外的子视图可见时,我希望所有触摸事件都由它处理 - 而不是滚动视图。
似乎前几个事件正在由子视图处理,但随后调用 touchesCancelled 并且滚动视图接管了触摸检测。
只要在该视图上执行移动活动,我如何确保子视图获取所有事件?
这是我在 touchesMoved 上的实现——我认为它可以完成这项工作......
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[touches allObjects] objectAtIndex:0];
CGPoint touchPt = [touch locationInView:self];
UIView *hitView = [self hitTest:touchPt withEvent:event];
UIView *mySubView = subviewCtrl.view;
if(hitView == mySubView) {
[subviewCtrl.view touchesMoved:touches withEvent:event];
}
else {
NSLog(@"Outside of view...");
}
}
【问题讨论】:
标签: iphone cocoa-touch iphone-sdk-3.0