如何在工作日的选择列表中设置重复UILocal通知 [英] How to set the repeat UILocal Notifications on the select list of Weekdays

查看:122
本文介绍了如何在工作日的选择列表中设置重复UILocal通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用以下链接实施 UILocal通知

I have implemented UILocal Notification using the following link

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

我已修改它以使用

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

例如ex 每天上午10点

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

But my requirement is user needsto set the notification on selected Week Days (Monday to saturDay)

为什么因为用户可能每周假期(周六和周日)/周五 - 周日)/其他几天 ..

why because user may have weekly holidays like (SaturDay and Sunday) / Friday - Sunday) / Some other days..

周假他不应该发出通知。

所以我们祝贺用户设置选中工作日和通知将仅在那些日期设置..一旦用户设置通知。

So we felicitate user to set the selected Working days and the notifications will set on those days only.. once user set the notifications.

例如:

我们有工作日Sun,MOn,星期二,星期三,星期四,星期五,星期六的清单

这些用户选择星期一,星期二,星期四,星期四。并设置为10Am

然后通知将在当天上午1​​0点开启。

如何操作

推荐答案

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

The API for UILocalNotification is very limited in this regard - you'll have to manually schedule 4 events repeating weekly on the days that the user selects.

为星期一安排重复计时器的示例如下所示

An example of scheduling a repeat timer for monday would look like this

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类参考

这篇关于如何在工作日的选择列表中设置重复UILocal通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆