【发布时间】:2012-03-24 20:08:18
【问题描述】:
我有一个 UILocalNotification 应该每天触发一次,从周一到周五,但不是在周末。我认为将通知的 repeatInterval 属性设置为 NSWeekdayCalendarUnit 可以完成此操作。对我来说可悲的是,我的通知仍然在周末触发。谁能建议为什么?这是我的代码:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertAction = @"View";
localNotification.alertBody = NSLocalizedString(@"ALERT_MESSAGE", nil);
localNotification.soundName = UILocalNotificationDefaultSoundName;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd-yyyy HH:mm"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"America/Toronto"]];
// Notification fire times are set by creating a notification whose fire date
// is an arbitrary weekday at the correct time, and having it repeat every weekday
NSDate *fireDate = [dateFormatter dateFromString:@"01-04-2012 11:00"];
localNotification.fireDate = fireDate;
localNotification.repeatInterval = NSWeekdayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
break;
[localNotification release];
【问题讨论】:
标签: ios ios5 uilocalnotification