【发布时间】:2016-09-05 02:52:53
【问题描述】:
该应用程序支持 iPad Pro,并且必须与 Apple Pencil 配合使用。我想做的是区分用户是使用 Apple Pencil 还是手指。
类似:
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,或者只是一个开始。网站上的教程也很完美,但我认为没有。
【问题讨论】:
标签: ios objective-c stylus-pen apple-pencil