2015-08-25 132 views
0

我,当我尝试使用下面的代码行:触摸位置

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { 
    for touch in touches { 
     let tap = touch as UITouch 
     let location = tap.locationInView(self.view) 
     print(location( 
} 

我不能让一个选择器视图内的触摸的位置。有没有办法做到这一点?

回答

0

这是我该怎么办,你需要指定你的对象的名称it..First,然后在你的touchesBegan需要指定触摸的位置与对象

let location = (touch as! UITouch).locationInNode(self) 
      if let name = self.nodeAtPoint(location).name { 
       if name == "objectName" { 
// do your code here 
} 
相同