6

次のリンクを使用してUILocal 通知を実装しました

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

そして、使用して毎日繰り返し通知を設定するように変更しました

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

例:毎日午前 10 時

しかし、私の要件は、ユーザーが選択した平日 (月曜日から土曜日) に通知を設定する必要があることです。

なぜユーザーは(SaturDay and Sunday) / Friday - Sunday) / Some other days のような毎週の休日を持っている可能性があるため..

上でweek offs he shouldn't fire the notifications.

したがって、ユーザーが選択した営業日を設定することを歓迎し、通知はそれらの日にのみ設定されます.. ユーザーが通知を設定すると.

For ex:

平日日、月、火、水、木、金、土の一覧です

それらのユーザーで、月曜日、火曜日、水曜日、木曜日を選択します。午前10時に設定

その後、通知は毎日午前 10 時に発生します。

どうやってするの

4

1 に答える 1

8

UILocalNotificationのAPIは、この点で非常に制限されています。ユーザーが選択した日に毎週繰り返される4つのイベントを手動でスケジュールする必要があります。

月曜日のリピートタイマーをスケジュールする例は次のようになります

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クラスリファレンスに記載されています。

于 2013-03-11T15:52:58.940 に答える