-2
我有这个代码可以让我的手机不断振动。但1次振动后停止。我的计时器有问题吗?我的计时器在一轮后停止
var timer: Timer?
@IBAction func button1(_ sender: UIButton) {
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
timer?.invalidate()
timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: Selector(("doaction")), userInfo: nil, repeats: true)
}
我做错了什么?帮帮我?我也用swift使用xcode。并有一个iPhone 7加上,如果重要的话。
也是我的iphone死机一次,我断开,并尝试运行应用程序 –
秀请'doaction'方法。毕竟,这是计时器重复呼叫的内容。 – matt