3 回答

TA貢獻1802條經驗 獲得超4個贊
要將觸摸從疊加視圖傳遞到其下的視圖,請在UIView中實現以下方法:
目標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貢獻1757條經驗 獲得超7個贊
這是一個舊線程,但是它是在搜索時出現的,因此我想添加2c。我有一個包含子視圖的UIView,并且只想攔截擊中一個子視圖的觸摸,所以我修改了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 關注
- 599 瀏覽
添加回答
舉報