gpt4 book ai didi

iphone - 如何在工作日的选择列表上设置重复 UILocal 通知

转载 作者:行者123 更新时间:2023-11-30 13:38:43 25 4
gpt4 key购买 nike

我已经使用以下链接实现了UILocal Notification

http://useyourloaf.com/blog/2010/07/31/adding-local-notifications-with-ios-4.html

我已经修改它以设置每天的重复通知

//To set the repeat notification
notif.repeatInterval = NSDayCalendarUnit;

例如每天上午 10 点

但我的要求是用户需要在选定的工作日(周一至周六)设置通知

为什么,因为用户可能有每周假期,例如(周六和周日)/周五 - 周日)/其他一些天..

休息周,他不应该触发通知。

因此,我们鼓励用户设置选定的工作日,并且通知将仅在这些日子设置..一旦用户设置通知。

例如:

我们有周日、周一、周二、周三、周四、周五、周六的列表

在这些用户上选择星期一、星期二、星期三、星期四。并设置为上午 10 点

然后通知将在这些天的每天上午 10 点触发。

如何做

最佳答案

UILocalNotification 的 API 在这方面非常有限 - 您必须手动安排 4 个事件,每周在用户选择的日期重复。<​​/p>

安排周一重复计时器的示例如下所示

NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.weekday = 2; // sunday = 1 ... saturday = 7
dateComponents.hour = 10;

UILocalNotification *notification = //...
notification.repeatInterval = NSWeekCalendarUnit;
notification.fireDate = [calendar dateFromComponents:dateComponents];

日期数字可以在 NSDateComponents Class Reference 中找到

关于iphone - 如何在工作日的选择列表上设置重复 UILocal 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35817272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com