gpt4 book ai didi

Swift OS X NSTouch 阶段 rawInput 到字符串?

转载 作者:行者123 更新时间:2023-11-30 12:15:35 26 4
gpt4 key购买 nike

似乎无法打印触摸阶段的字符串值已尝试过:

let phase = NSTouch.Phase(rawValue: touch.phase.rawValue)            
print(phase)

let touches = event.touches(matching: NSTouch.Phase.ended, in: self.view)
touches.forEach { (touch) in
print("🖖🏼 touch up \(touch.phase)")
}

我得到的输出是这样的

Phase(rawValue: 8)
🖖🏼﹣ touch up Phase(rawValue: 8)

最佳答案

这不是一个很好的解决办法:

print("Began", String(describing: NSTouch.Phase.began))
print("Ended", String(describing: NSTouch.Phase.ended))
print("Moved", String(describing: NSTouch.Phase.moved))
print("Stationary", String(describing: NSTouch.Phase.stationary))
print("Touching", String(describing: NSTouch.Phase.touching))
print("Cancelled", String(describing: NSTouch.Phase.cancelled))

结果帮助产生了这个:

let phases = [
"1":"Began",
"2":"Moved",
"4":"Stationary",
"7":"Touching",
"8":"Ending",
"16":"Cancelled"
]

let phase = phases["\(touch.phase.rawValue)"]
print("🖖 Finger touch down \(phase)")

关于Swift OS X NSTouch 阶段 rawInput 到字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45473570/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com