iOS - 通过视图转发所有触摸 [英] iOS - forward all touches through a view

查看:126
本文介绍了iOS - 通过视图转发所有触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个覆盖在许多其他视图之上的视图。我只是使用overaly来检测屏幕上的一些触摸,但除此之外,我不希望视图阻止下面的其他视图的行为,哪些是滚动浏览等。如何将所有触摸转移到这个重叠视图?它是UIView的subcalss。

解决方案

对于将覆盖视图传递到下面的视图,请在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆