0
我在xcode中创建了一个应用程序,该应用程序永远随着按钮振动,并停止使用按钮,但是当我在iPhone上测试它时,它不会振动。帮帮我?我的swift代码不会执行振动
var timer: Timer?
@IBAction func button1(_ sender: UIButton) {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
timer?.invalidate()
timer = Timer.scheduledTimer(timeInterval: 0.0, target: self, selector: Selector(("doaction")), userInfo: nil, repeats: true)
}
@IBAction func button2(_ sender: UIButton) {
timer?.invalidate()
timer = nil
}
我也使用iPhone 7 plus,如果这有所作为。
确保您的移动振动不会被设置为关闭做呢?它仅在移动振动打开时起作用。 –
我该如何开启它? –
设置 - >声音 - >你必须振动 –