UIView对Apple Pencil不反应 [英] UIView do not react on Apple Pencil

查看:94
本文介绍了UIView对Apple Pencil不反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,某些UIView对Apple Pencil没有反应.当我用手指触摸时,一切正常.我以为这可能是由于在iOS 9中添加了新属性type引起的.我试图更改触摸的类型:

In my app some of UIViews don't react on Apple Pencil. When I make touch by finger, all works fine. I supposed that this might be caused by adding new property type in iOS 9. And I tried to change the type of touches:

touch.type = UITouchTypeDirect;

但这是只读属性.是否存在通过手指和Apple Pencil进行均匀触摸的任何方式?

But this is readonly property. Does exist any way to make equal touch by finger and touch by Apple Pencil?

如何使我的应用程序在Apple Pencil上做出反应?

推荐答案

UITouch类确定触摸是由触控笔还是由手指进行的,因为触控笔具有精确的触感,而手指具有柔和的角触感.您不必为苹果铅笔指定任何设置.

UITouch class determines whether the touch is made by a stylus or by a finger, as stylus have a pinpoint touch and finger has a soft corner touch. You don't have to specify any setting for apple pencil.

touches began方法中,

您可以将触摸方式区分为:

you can differntiate the touches as:

   if(touch.type==UITouchTypeStylus){
               //perform stylus action
   }

这篇关于UIView对Apple Pencil不反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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