स्विफ्ट 3 के लिए, @ एंड्रयू उत्तर के आधार पर:
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)
}
}
संपादित करें, मेरा बुरा है, वह नहीं है उन के माध्यम से पुनरावृति करने के लिए, इस प्रकार के रूप में UITouch का एक सेट वस्तुओं छूता संग्रह डाली आपके सवाल का जवाब देने, एक ही समस्या थी और किसी this previous answer करने के लिए मुझसे जुड़ा हुआ: वैसे भी
, मैं इसे तेजी से 3 में काम करता है बनाने के लिए कुछ चीजें बदलना पड़ा, यहाँ मेरे वर्तमान कोड है:
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
}
}
}
}
मुझे अभी भी एक छोटी सी समस्या है लेकिन मुझे लगता है कि यह मेरे कोड में मेरे जेस्चर रिकॉग्नाइज़र से जुड़ा हुआ है। लेकिन यह चाल करना चाहिए। यह आपको आपके कंसोल में प्रत्येक बिंदु के समन्वय को मुद्रित करेगा।
अपने जवाब के लिए धन्यवाद! मैंने जियोराशक के उत्तर को सबसे उपयोगी बताया क्योंकि उसने थोड़ा और जानकारी दी, लेकिन दोनों विधियां काम करती हैं :) – Fr4nc3sc0NL
आपका स्वागत है! यह आपकी कॉल है, बेशक :) मैंने जवाब को थोड़ा सा और दस्तावेज के बाएं संदर्भों को संपादित किया है, यह बताते हुए कि मल्टी-टच सक्षम करने के लिए यह महत्वपूर्ण है या कोड काम नहीं करेगा (हम हमेशा इसके बारे में भूल जाते हैं!)। मैं इस उत्तर को अन्य लोगों के संदर्भ के रूप में छोड़ रहा हूं जिन्हें उस विवरण की आवश्यकता हो सकती है :) – Para