我的代码:
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 怎么修呢?
发布于 2015-09-23 11:49:56
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
}
}
}
}发布于 2015-09-23 12:16:46
尝尝这个
if let touch = touches.first as? UITouch
{
}https://stackoverflow.com/questions/32737965
复制相似问题