简体   繁体   English

检测手掌触摸/释放 iphone 屏幕

[英]Detect palm touching/releasing the iphone screen

Implementing a sort of 'distress call' button which should work as following:实现一种“遇险呼叫”按钮,其工作方式如下:

  1. User starts application and covers a screen with a palm of a hand用户启动应用程序并用手掌覆盖屏幕
  2. Some time passes, user may introduce additional touches during that time or remove some of the existing (but not all of them), location/shape of touches may change一段时间过去,用户可能会在此期间引入额外的触摸或删除一些现有的(但不是全部),触摸的位置/形状可能会改变
  3. When user releases a hand (ie removes last touch) a distress signal is emitted by the app当用户松开手(即移除最后一次触摸)时,应用程序会发出求救信号

Basically, the app should register two events: (1) a screen is touched (2) all touched are released基本上,应用程序应该注册两个事件:(1)触摸屏幕(2)释放所有触摸

I'm trying to use touchesBegan/touchesEnded methods and those work for small area touches (fingertips) but on touching screen with a full palm or even only palm edge a touchesCancelled gets triggered immediately while hand is still on the screen.我正在尝试使用 touchesBegan/touchesEnded 方法,这些方法适用于小区域触摸(指尖),但在全掌或什至只有手掌边缘的触摸屏上,当手仍在屏幕上时,会立即触发 touchesCancelled。 Obviously no other events are emitted upon hand release afterwards.显然,之后在手动释放时不会发出其他事件。

I tried subclassing UIWindow and UIApplication and overriding sendEvent in those but got no additional info - large area touches are triggering touch begin and immediately touch cancel, releasing hand afterwards emits nothing.我尝试将 UIWindow 和 UIApplication 子类化并在其中覆盖 sendEvent ,但没有得到其他信息 - 大面积触摸正在触发触摸开始并立即触摸取消,然后松开手不会发出任何信号。 In some cases large area touches fire no events at all, not even the touchesBegan.在某些情况下,大面积触摸根本不会触发任何事件,甚至 touchesBegan 也不会触发。 Basically, iOS doesn't let me work with a very basic scenario - detecting just the fact of screen touch/release.基本上,iOS 不允许我使用非常基本的场景 - 仅检测屏幕触摸/释放的事实。

Is there any way to query the screen touch state directly and not work with responder chain?有什么方法可以直接查询屏幕触摸 state 而不能与响应链一起使用? Or suppress the cancellation event from firing?或者抑制取消事件触发? Or maybe I'm missing something?或者,也许我错过了什么?

Unfortunately, as of right now, no solution exists不幸的是,截至目前,尚无解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM