,:
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
let touchSet = touches
for touch in touchSet{
let location = touch.location(in: self.view)
print(location)
}
}
EDIT'e, Benim hatam, o değil UITouch bir Set nesneleri olarak aşağıdaki gibi içlerinden yineleme için dokunuşlar koleksiyonu dökme sorunuzu yanıtlamadan, aynı problem vardı ve birisi this previous answer beni bağlantılı: Ben hızlı 3'te çalıştığından emin olmak için birkaç şey değiştirmek zorunda Neyse
, burada benim geçerli kod:
var fingers = [String?](repeating: nil, count:5)
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
for touch in touches{
let point = touch.location(in: self.view)
for (index,finger) in fingers.enumerated() {
if finger == nil {
fingers[index] = String(format: "%p", touch)
print("finger \(index+1): x=\(point.x) , y=\(point.y)")
break
}
}
}
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesMoved(touches, with: event)
for touch in touches {
let point = touch.location(in: self.view)
for (index,finger) in fingers.enumerated() {
if let finger = finger, finger == String(format: "%p", touch) {
print("finger \(index+1): x=\(point.x) , y=\(point.y)")
break
}
}
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
for touch in touches {
for (index,finger) in fingers.enumerated() {
if let finger = finger, finger == String(format: "%p", touch) {
fingers[index] = nil
break
}
}
}
}
Hala biraz sorunum var ama bence kodumdaki GestureRecognizer ile bağlantılı. Ama bu hile yapmalı. Size, konsolunuzdaki her bir noktanın koordinatını yazdıracaktır.
Cevabınız için teşekkür ederiz! Giorashc'ın cevabını en yararlı olarak işaretledim çünkü biraz daha fazla bilgi verdi, ama her iki yöntem de işe yarar :) – Fr4nc3sc0NL
Bir şey değil! Bu sizin aramanız, tabii ki :) Cevabı biraz düzenledim ve belgelere referanslar bıraktım, çoklu dokunmayı etkinleştirmenin ya da kodun çalışmaz hale gelmesinin altını çiziyor (bunu her zaman unutuyoruz!). Bu cevabı bu ayrıntıya ihtiyaç duyabilecek diğer insanlar için referans olarak bırakıyorum :) – Para