3 回答

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超4個(gè)贊
要將觸摸從疊加視圖傳遞到其下的視圖,請(qǐng)?jiān)赨IView中實(shí)現(xiàn)以下方法:
目標(biāo)C:
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
NSLog(@"Passing all touches to the next view (if any), in the view stack.");
return NO;
}
迅速:
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
print("Passing all touches to the next view (if any), in the view stack.")
return false
}

TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超7個(gè)贊
這是一個(gè)舊線程,但是它是在搜索時(shí)出現(xiàn)的,因此我想添加2c。我有一個(gè)包含子視圖的UIView,并且只想攔截?fù)糁幸粋€(gè)子視圖的觸摸,所以我修改了PixelCloudSt的答案
-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
for (UIView* subview in self.subviews ) {
if ( [subview hitTest:[self convertPoint:point toView:subview] withEvent:event] != nil ) {
return YES;
}
}
return NO;
}
- 3 回答
- 0 關(guān)注
- 603 瀏覽
添加回答
舉報(bào)