【发布时间】:2023-03-12 02:39:01
【问题描述】:
我有这个代码可以让我的手机不断振动。但它在 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)
}
我做错了什么?帮助?我也在快速使用xcode。如果这很重要,请拥有一部 iphone 7 plus。
【问题讨论】:
-
一旦我断开连接并尝试运行应用程序,我的 iphone 也会崩溃
-
请显示
doaction方法。毕竟,这就是计时器反复调用的内容。
标签: ios iphone swift vibration