2017-06-15 57 views
1

有没有办法检测iPad的型号是否支持Apple Pencil?检测iPad是否可以使用Apple Pencil(是iPad Pro)

我可以检查返回iPad模型的[UIDeviceHardware platformString],我可以获得Pro模型,但是我想要一个即使是未来的iPad Pro模型也能使用的权威解决方案。

+0

也许这可以帮助:https://stackoverflow.com/questions/37133248/how-to-differentiate-whether-a-user-is-tapping-the-screen-with-his-finger-or-一个或许可能不正是你想要的,但你可以在https://stackoverflow.com/questions/32542250/detect-whether-apple-pencil-is-connected-to-an-ipad-pro?rq=1 – rmaddy

+0

或者使用以下命令检测是否连接了Apple Pencil:https://stackoverflow.com/a/41264961/1489885或使用此设备运行的设备:https://github.com/dennisweissmann/DeviceKit – HAS

+0

检测结果连接的Apple Pencil不适用于我。只需要知道iPad是否有能力。 –

回答

0

您可以使用forceTouchCapability API检查设备是否支持3D Touch,并且还可以检查设备是否为带有userInterfaceIdiom的iPad。目前,没有API可用于检测手指用于iPad或Apple Pencil for iPhone的3D Touch可用性。

if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad && 
    UIScreen.mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) 
{ 
    // this device in current state supports stylus 
} 
相关问题