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 关注
- 566 浏览
添加回答
举报