该应用支持iPad Pro,并且需要与Apple Pencil配合使用。我想要做的是区分用户是使用Apple Pencil还是手指。
类似于以下内容:
我找到了
我的主要问题是,很少有例子,而且它们都是用Swift编写的,但我正在使用Objective-C。我真的无法理解这些示例。
看看这个,这是我在苹果开发者网站上找到的一个示例函数:
类似于以下内容:
if( the user is pressing the screen with his finger){
do something
} else if ( the user is pressing the screen with an Apple Pencil){
do something else
}
我找到了
UITouchTypeStylus
属性,但不知道它是如何工作的。我的主要问题是,很少有例子,而且它们都是用Swift编写的,但我正在使用Objective-C。我真的无法理解这些示例。
看看这个,这是我在苹果开发者网站上找到的一个示例函数:
func addPointsOfType(var type: LinePoint.PointType, forTouches touches: [UITouch], toLine line: Line, currentUpdateRect updateRect: CGRect) -> CGRect {
var accumulatedRect = CGRect.null
for (idx, touch) in touches.enumerate() {
let isStylus = touch.type == .Stylus // I think that what I'm looking for is something like that
[...]
}
很不幸,我现在没有时间学习Swift……这完全阻碍了我的进展。
所以如果有人能提供一些Objective C的示例代码,使我能够使用Apple Pencil或开始使用它那就太好了。一个网站上的教程也是完美的,但我认为没有这样的资源。
UITouch
对象,示例代码仅用于测试触摸类型,这也是您所要求的。 - jrturton