gpt4 book ai didi

ios - 错误为 "touchesBegan"

转载 作者:行者123 更新时间:2023-11-30 14:03:08 26 4
gpt4 key购买 nike

我的代码:

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 

如何解决?

最佳答案

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
}
}
}
}

关于ios - 错误为 "touchesBegan",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32737965/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com