斯威夫特播放闹钟声

时间:2016-02-22 03:26:27

标签: ios swift audio alarm uialertcontroller

当用户用完时,我会弹出警报。现在它只是振动但我也希望它发出警报声。有没有办法播放用户设置的任何系统默认警报声?此外,是否可以让警报继续运行,直到用户点击关闭按钮?

到目前为止,这是我的代码:

func dismissAlert(alert:UIAlertAction!)
        {
            self.dismissViewControllerAnimated(true, completion: nil)
        }

let outOfTimeAlert = UIAlertController(title: "Out Of Time", message: "Better luck next time", preferredStyle: UIAlertControllerStyle.Alert)

let cancelAlert: UIAlertAction = UIAlertAction(title: "Dismiss", style: .Cancel, handler: dismissAlert)

outOfTimeAlert.addAction(cancelAlert)

presentViewController(outOfTimeAlert, animated: true, completion: nil)

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)

感谢您的帮助!

0 个答案:

没有答案