2015-09-05 96 views
0

當用戶觸摸屏幕時,我想獲取屏幕的座標。 我嘗試touchesBegan方法,但是當我使用NSSet作爲參數時出現錯誤。任何人都可以指導我在哪裏我錯了如何解決這個問題。用戶觸摸時獲取屏幕座標

預先感謝...

override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { 
    let touch = touches.anyObject()! as! UITouch 
    lastPoint = touch.locationInView(self) 
} 

錯誤:重寫方法與選擇器 '的touchesBegan:withEvent:方法' 具有不兼容的類型 '(NSSet中,的UIEvent)'

回答

0

使用嘗試:

let touch = touches.first() as? UITouch 
+0

不,這是行不通的... **錯誤**:NSSet沒有一個名爲第一個成員 – Uzair