UIView对Apple Pencil不反应 [英] UIView do not react on Apple Pencil
问题描述
在我的应用中,某些UIView
对Apple Pencil没有反应.当我用手指触摸时,一切正常.我以为这可能是由于在iOS 9中添加了新属性type
引起的.我试图更改触摸的类型:
In my app some of UIView
s 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屋!