iOS - 通过视图转发所有触摸 [英] iOS - forward all touches through a view
本文介绍了iOS - 通过视图转发所有触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
对于将覆盖视图传递到下面的视图,请在UIView:
Objective-C:
- (BOOL)pointInside :(CGPoint)point withEvent:(UIEvent *)event {
NSLog(@将所有触摸传递到视图堆栈中的下一个视图(如果有的话)。
返回NO;
}
Swift:
覆盖func点(内点:CGPoint,事件:UIEvent?) - > Bool {
print(将所有触摸传递到视图堆栈中的下一个视图(如果有的话))
返回false
}
I have an view overlayed on top of many other views. I am only using the overaly to detect some number of touches on the screen, but other than that I don't want the view to stop the behavior of other views underneath, which are scrollviews, etc. How can I forward all the touches through this overlay view? It is a subcalss of UIView.
解决方案
For passing touches from an overlay view to the views underneath, implement the following method in the UIView:
Objective-C:
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
NSLog(@"Passing all touches to the next view (if any), in the view stack.");
return NO;
}
Swift:
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
}
这篇关于iOS - 通过视图转发所有触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文