如何使用UIDatePicker设置闹钟?
我正在 iPhone 上开发一个闹钟应用程序。我无法找到如何设置即使应用程序未运行也会触发的警报。
I am developing an alarm clock application in iphone. I am not able to find how to set alarm which will trigger even if the app is not running.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
本地通知!
(这是自 iOS 4.0 以来现在的正确答案,所以请给我积分!(jk))
Local notifications!
(This is now the correct answer since iOS 4.0 so gimme the credits!! (jk))
推送通知...或者...
前几天我注意到,如果我关闭屏幕(使用顶部的按钮),我的应用程序仍在获取 GPS 更新...
所以,我开始思考只是点击顶部按钮实际上并不会退出您的应用程序...您需要做一些实验来证明这一点...但也许您仍然可以在屏幕关闭的情况下播放声音?
Push notifications... OR....
The other day I noticed that if I turned off the screen (with the button on the top) that my app was still getting gps updates....
So, I'm starting to think that just hitting the top button doesn't actually exit your app... You'd need to do some experiments to prove this... but maybe you could still play a sound with the screen off?
目前确实没有好的、干净的解决方案。我能找到的最好的就是一个类(http://code.google .com/p/iphone-insomnia/),阻止其睡眠。通过这种运行,您可以做任何您想做的事情,但它很可能会很快耗尽电池电量。
另一种解决方案是 iPhone 在充电时不会休眠。因此,您可以简单地提醒您的用户,只有在设置之前 iPhone 正在充电时,闹钟才会起作用,并且他们无法离开该应用程序。
There really is no good, clean solution at the moment. The best that I've been able to find is a class (http://code.google.com/p/iphone-insomnia/) that stops it from sleeping. With this running, you can do whatever you want, but it will most likely drain the battery quite fast.
One other half solution is that the iphone doesn't sleep if it is charging. So you could simply alert your users that the alarm will only work if the iPhone is charging before it is set and that they cannot leave the app.