本文介绍了在模拟器中模拟 Apple Pencil 似乎是可能的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在 iOS 模拟器中模拟 Apple Pencil.

I was wondering if it is possible to simulate the Apple pencil in the iOS simulator.

据此处的 Apple 员工所述 Xcode iOS 模拟器:我可以将鼠标用作假装 Apple Pencil 输入(在 iPad Pro 上)进行测试吗? 这是不可能的.并且在 2017 年 6 月给出了答案.

According to an Apple emloyee here Xcode iOS Simulator: can I use the mouse as pretend Apple Pencil input (on iPad Pro), for testing? it is not possible. And the answer was given in June 2017.

根据https://developer.xamarin.com/guides/cross-platform/windows/ios-simulator/(最后一段:Windows 中的手写笔支持也被转换为模拟器上的 Apple Pencil 输入.),使用远程 iOS 模拟器在 Xamarin 中,可以模拟铅笔.(他们已经有这个功能几个月了)

According to https://developer.xamarin.com/guides/cross-platform/windows/ios-simulator/ (very last paragraph: Stylus support in Windows is also translated to Apple Pencil input on the simulator.), using the remote iOS simulator from Xamarin, it is possible to simulate the pencil. (and they have had this feature for some months already)

所以,我有点困惑.据我所知,Xamarin 也使用普通的 iOS 模拟器.(他们只是通过 Windows PC 上的远程连接显示它)如果他们在模拟器中支持铅笔,那么对于任何人来说都必须是可能的,不是吗?

So, I am a bit confused. As far as I know, Xamarin uses the normal iOS simulator, too. (They just show it via a remote connection on a Windows PC) If they have pencil support in the simulator, it must be possible for anybody, mustn't it?

推荐答案

对于那些在 2021 年仍然坚持这一点的人,请尝试以下操作:

For those who stuck with this in 2021 try the following:

iOS 14

#if targetEnvironment(simulator)
canvasView.drawingPolicy = .anyInput
#else
canvasView.drawingPolicy = .pencilOnly
#endif

在设置"应用中还有一个名为仅使用 Apple Pencil 绘图"的全局设置.这可以从 PencilKit 中的 UIPencilInteraction.prefersPencilOnlyDrawing 读取.

Also in the Settings app there is a global setting called "Only Draw with Apple Pencil". This can be read from UIPencilInteraction.prefersPencilOnlyDrawing in PencilKit.

iOS 13(仅限)

#if targetEnvironment(simulator)
canvasView.allowsFingerDrawing = true
#else
canvasView.allowsFingerDrawing = false
#endif

https://stackoverflow.com/a/62567169/2667933 提供

这篇关于在模拟器中模拟 Apple Pencil 似乎是可能的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 06:06