【发布时间】:2017-10-10 01:56:47
【问题描述】:
我在 xcode 中制作了一个应用程序,它通过一个按钮永远振动,并通过一个按钮停止,但是当我在我的 iphone 上测试它时它不会振动。帮忙?
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,如果这有什么不同的话。
【问题讨论】:
-
确定您的手机振动没有设置为关闭?仅在手机震动开启时有效。
-
如何开启?
-
设置 -> 声音 -> 你必须在振动
标签: ios iphone swift vibration