将 UIEvent 从 iOS 设备 UIView 发送到外部屏幕 UIView

发布于 2024-12-03 13:28:37 字数 616 浏览 1 评论 0原文

我正在开发一个使用 AirPlay 的应用程序,我需要一种方法让主屏幕上的触摸充当外部屏幕上 UI 上的触摸,以便与大量先前存在的自定义 UI 元素兼容。重建 UI 元素比找到一种将触摸从一个视图转换为另一个视图的方法要困难几个数量级。

外部屏幕将采用一种鼠标指针来表示交互,因为用户需要屏幕上的参考点来进行操作。这可能会造成用户界面指南障碍,但当我到达它时我会越过那座山。希望我能找到一种方法让这个项目足够不像鼠标。用户将像触控板一样与设备进行交互。

我在设备屏幕上使用一个带有“sendEvent”子类的窗口来捕获触摸事件。我正在尝试手动遍历需要接收输入的视图的视图层次结构。找到我想要交谈的观点并不困难。对于基于 UIControl 的类,我可以调用“sendActionsForControlEvents”来发送控件的适当消息。这可能需要一些照顾,但目前这不是主要问题。

对于touchesBegan、touchesMoved等UI事件,我没有一个好的方法来伪造UIEvent信息。除非我有 UIEvent,否则我无法调用这些函数,而且我似乎没有任何方法来创建 UIEvent 对象。 sendEvent 中的 UIEvent 没有与辅助屏幕上的指针位置匹配的位置(至少),因此简单地传递它不会给我我想要的东西。

有没有合法的方法来合成这些信息?

I'm working on an app using AirPlay and I need a way to have touches on the main screen act as touches on the UI on my external screen in order to be compatible with a large number of previously existing custom UI elements. Rebuilding the UI elements would be orders of magnitude more difficult than finding a way of translating the touches from one view to another.

The external screen will feature a sort of mouse pointer to represent the interaction, as the user will need a point of reference on the screen for their actions. This may create User Interface guidelines hurdles, but I'll cross that mountain when I get to it. Hopefully I can find a way to make this item sufficiently non-mouse like. The user will interact with the device as a sort of track-pad.

I'm using a window on the device screen with "sendEvent" subclassed to catch the touch events. I'm attempting to manually walk the view hierarchy for the views that need to receive input. Finding the view I want to talk to is not difficult. For UIControl based classes I can call "sendActionsForControlEvents" to send the appropriate messages for the control. This may need some caressing, but for now that's not the main issue.

For the UI events for touchesBegan, touchesMoved, etc. I don't have a decent way of faking the UIEvent information. I can't call these functions unless I have a UIEvent, and I don't seem to have any way of create a UIEvent object. The UIEvent from sendEvent does not have a position that matches the pointer position on the secondary screen (at the least), so simply passing it on will not give me what I want.

Is there any legitimate way of synthesizing this information?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文