我已经使用以下链接实现了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/15342546/