2015-09-23 4 views
0

Мой код:Ошибка с "touchesBegan"

var location = CGPoint(x:0,y:0) 
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { 
    let touch = touches.anyObject() as? UITouch 
    location = touch.locationInView(self.view) 
    Button.center = location 
} 

дает ошибку на этой линии:

let touch = touches.anyObject() as? UITouch 

Как это исправить?

ответ

0
Try this : - 

    override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { 

    for touch in touches { 
    if let touch = touches.first as? UITouch { 
          if touch.tapCount == 2{ 
           //Do Something here 
          } 
              } 
          } 
     } 
0

попробовать это

if let touch = touches.first as? UITouch 
{ 
} 
Смежные вопросы