安排 UILocalNotifications 每天或一周中的特定日期?
我正在开发一个需要设置本地通知的警报项目,但问题是我需要在每个星期日或每个星期一重复它们,或者可能在星期日或星期一都重复它们, 任何人都可以帮我解决这个问题吗? 谢谢
I am working on an Alarm project which needs to set Local Notifications but the problem is that i need to repeat them on Every sunday or every monday or might be on both of sunday or monday ,
can Any one help me how to solve it,?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UILocalNotification 有一个名为
repeatInterval
的属性。但是,它仅指定您希望重复通知的时间间隔,具体取决于用户指定的
fireDate
。假设火灾日期是星期一;如果像这样设置重复间隔,则
通知将在每个星期一发出。
现在,如果您想在星期一和星期日都有重复通知,则必须创建 2 个不同的本地通知对象,一个为星期一设置 fireDate,另一个为星期日设置 fireDate,并且两者都带有
repeatInterval<为
kCFCalendarUnitWeekday
设置的 /code> 属性。UILocalNotification has a property called
repeatInterval
.However, it only specifies the interval at which you want the notification to repeat, depending on the
fireDate
that your user specified.Say, the fire date was on a monday; if the repeat interval was set like so,
the notification would go off every single monday.
Now, if you want to have repeating notifications for a monday and a sunday both, you would have to create 2 different Local Notification objects, one with a fireDate set for monday and another set for sunday, and both with the
repeatInterval
property set forkCFCalendarUnitWeekday
.我猜重复就是问题所在。看看这个。
我猜您知道您实例化了一个 UILocalNotification 对象,然后使用 UIApplication 方法
scheduleLocalNotification:
来安排它。正如您可以在文档,第四段文字。i'm guessing that it is the repeating that is the problem. take a look at this.
and i guess you know that u instantiate a UILocalNotification object and then you schedule it using the UIApplication method
scheduleLocalNotification:
. as you can read in the documentation, 4th text passage.