我在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...");
}
}