iOS 11.1游戏的顶部和底部对触摸无响应 [英] Top and bottom of iOS 11.1 games unresponsive to touch

查看:86
本文介绍了iOS 11.1游戏的顶部和底部对触摸无响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从安装iOS 11.1以来,我们已经观察到屏幕顶部和底部的条带已变得对触摸无响应.这会影响我开发的风景应用程序和人像应用程序(它们使用金属API进行渲染).在其他一些开发人员的应用程序中也发现了该问题,例如高尔夫冲突(Golf Clash),而不是其他应用程序-由于我们使用内部引擎,因此我们的应用程序与其他开发人员的应用程序之间没有共享的代码.

Since installing iOS 11.1 we have observed that a strip along the top and bottom of the screen has become unresponsive to touches. This affects both a landscape app and a portrait app which I develop for (they use metal API for rendering). The issue has also been observed on some other developer's apps e.g. Golf Clash but not others - as we use an in-house engine there is no shared code between our apps and other developer's apps.

这是功能更改还是解决方法的已知问题?我在StackOverflow或Apple Developer论坛或Apple文档中找不到任何信息.

Is this a functionality change or known issue with workaround? I can't find any information on StackOverflow or in the Apple Developer forums or in Apple documentation.

也许这与iOS 11中出现的安全区域的引入有关,我们的标题尚未完全支持(但是我不希望安全区域影响触摸或出现在现有设备上).可能与新的通知向下滑动和控制中心向上滑动行为有关-我们注意到他们曾经在第一次滑动时打开一个标签页,但是现在它们立即打开,但是进入设置并禁用控制中心在应用程序中无法解决该问题.

Perhaps it relates to the introduction of safe zones that appeared in iOS 11 which our titles are not fully supporting yet (but I wasn't expecting safe zones to affect touch, or to appear on existing devices). Perhaps it relates to the new notification swipe-down and control center swipe-up behaviour - we've noticed they used to open a tab on the first swipe, but now they immediately open, however, going into the settings and disabling the control center in apps doesn't fix it.

在iPhone6和iPhone6S上都可以看到,因此不太可能与3D触摸功能相关,因为iPhone6不支持该功能.

Observed on both an iPhone6 and an iPhone6S, so it's unlikely to relate to 3D touch features as the iPhone6 does not support that.

睡眠一段时间后将进行进一步的调查,但是我认为实际上正在生成违规区域的触摸事件.问题是计时的问题之一,即使在快速按下的情况下,通常在touchesEnded事件之前约20-50ms会收到touchesBegan事件.但是,在这些顶部和底部区域,几乎在touchesBegan(小于1ms)之后立即收到touchesEnded事件.我的工作原理是,iOS会阻止touch事件来查看它是否成为轻拂手势,并且仅在确定不会将其作为轻拂处理时才发送touchesBegan事件.可能必须改进我的输入代码,以使一开始就结束的触摸不会落入裂缝,并最终被游戏代码所忽略(不幸的是,它会轮询触摸状态而不是事件驱动).

Will investigate further after some sleep, but I think that the touch events for the offending regions are in fact being generated. The problem is one of timing, normally the touchesBegan events are received about 20-50ms before the touchesEnded events, even for quick presses. However, in these top and bottom areas, I receive the touchesEnded event almost immediately after touchesBegan (less than 1ms). My working theory is that iOS is holding back the touch event to see if it becomes a swipe gesture, and only sends the touchesBegan event once it decides it won't be handled as a swipe. Probably will have to improve my input code so that a touch that ends as soon as it begins doesn't fall through the cracks and ends up ignored by the game code (which unfortunately polls the touch state rather than being event driven).

推荐答案

在这里回答我自己的问题:

Answering my own question here:

iOS11.1确实改变了屏幕顶部和底部的触摸事件计时.大概是为了处理用于打开通知和控制中心的新的单次滑动手势. touchesBegan事件和touchesEnded事件几乎完全同时出现.

It does indeed appear that iOS11.1 changes the timing for touch events at the top and bottom of the screen. Presumably this is in order to handle the new single-swipe gestures for opening notifications and the control center. The touchesBegan events and touchesEnded events appear at almost exactly the same time.

我相信,如果我提交了Radar,Apple会认为行为更改是按设计(合理地如此)进行的.但是,遵循将触摸事件处理为触摸状态,然后轮询该触摸状态以检测按钮按下的应用程序可能会中断.该方法之所以失败,是因为这些触摸在添加后立即从触摸状态中删除,而轮询代码没有机会观察到它们.

I believe that if I did file a Radar that Apple would consider the behaviour change as-designed (and reasonably so). However, Apps that follow the pattern of processing touch events into a touch state, and then poll that touch state to detect button presses are likely to break. The approach fails because these touches get removed from the touch state immediately after being added with no opportunity for the polling code to observe them.

最好的解决方法可能是使输入处理在整个App中由事件驱动.我认为这对我来说是不切实际的,因为可能会影响多个项目的代码量.我的解决方法是检测这种情况,并在应用程序有机会注意到发生触摸之前,不允许touchesEnded事件影响触摸状态.

The best fix is probably to make input handling event-driven throughout the App. I felt that was impractical in my case due to the amount of code that would be impacted across multiple projects. My fix was to detect the situation and not allow a touchesEnded event to affect the touch state until after the App had a chance to notice that the touch had taken place.

顺便说一句,如果在辅助功能设置"中启用放大手势",则在Android上也会观察到类似的行为(同样,操作系统将从应用程序中保留触摸事件,直到它确定未发生手势为止-在这种情况下,三连击).我很高兴在解决此iOS11.1问题时,还解决了我的Android应用程序也与放大手势"不兼容的事实.

As an aside, similar behaviour can be observed on Android if you enable Magnification Gestures in Accessibility Settings (again the OS is holding back touch events from the App until it determines that a gesture isn't taking place - in this case a triple-tap). I'm pleased that in fixing this iOS11.1 issue, I've also addressed the fact that my Android apps were incompatible with Magnification Gestures too.

这篇关于iOS 11.1游戏的顶部和底部对触摸无响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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