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