我有3個相同大小的UIViews堆疊在一起。最頂端是透明的,僅用於檢測觸摸。檢測到的觸摸類型將決定我想要接收觸摸事件的其他兩個基礎視圖中的哪一個。一旦最上面的視圖完成觸摸,我需要將觸摸事件轉發到正確的基礎視圖。我怎樣才能做到這一點?iOS - 如何將觸摸轉發到底層uiview
編輯 - 我添加了我的觸摸檢測代碼。這在MainViewController中,其視圖包含所有3個子視圖。
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches)
{
if (touch.view == self.touchOverlay) {
CGPoint touchLocation = [touch locationInView:touch.view];
//do a bunch of math to determine which view should get the touches.
if (viewAshouldGetTouches) //forward to viewA
if (viewBshouldGetTouches) //forward to viewB
}
}
}
所有UIView的單個視圖的子視圖? – Putz1103
@ Putz1103是的,他們是單個視圖的子視圖。我在視圖控制器中檢查touchesMoved等,而不是包含視圖。 – soleil