Objective c UILocalNotification重复间隔
我有两个问题Objective c UILocalNotification重复间隔,objective-c,uilocalnotification,Objective C,Uilocalnotification,我有两个问题 如果我了解本地通知,repeatinterval允许我安排一次通知,并在每周、每月或每周的同一时间间隔重复该通知。我试图让repeatinterval在星期二发射一次,并且每周都会在同一天(即星期二)再次发射。这应该每周进行一次,无需安排另一次通知。对吗。这一切都没有发生。我不是在代码中做错事,就是在测试它 在模拟器中,我运行应用程序调度通知。我看到的通知出现了。然后我退出应用程序,并将系统日期设置为未来一周的同一天,但没有通知,因此我可以通过更改计算机系统时钟来测试此通知。我不想
- (void) scheduleNotificationWithItem:(NSDate *)date interval:(int)frequency {
UILocalNotification *localNotif = [[UILocalNotification alloc]init];
if (localNotif == nil) {
return;
}
localNotif.fireDate = [date addTimeInterval:frequency];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.repeatCalendar = [NSCalendar currentCalendar];
localNotif.repeatInterval = kCFCalendarUnitWeekday;
localNotif.applicationIconBadgeNumber = 1;
localNotif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"%@.",nil),@"Weekly Reminder"];
localNotif.alertAction = NSLocalizedString(@"View Notification Details", nil);
localNotif.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication]scheduleLocalNotification:localNotif];
[localNotif release];
}
请帮帮我,这快把我逼疯了。
谢谢
Dean1)将重复间隔设置为“NSWeekCalendarUnit”应该可以做到这一点。它每周在与原始通知相同的日期和时间重复
2) 我没有在模拟器中进行测试,但在实际的iPhone上更改时钟确实会触发未来的警报。1)将重复间隔设置为“NSWeekCalendarUnit”应该可以做到这一点。它每周在与原始通知相同的日期和时间重复
2) 我没有在模拟器中进行测试,但在实际的iPhone上更改时钟确实会触发未来的警报。对于#2,如果您在运行模拟器的任何设备(Macbook或其他Mac[或Hackintosh])上更改系统时钟,它会在模拟器中工作。我已经在5.1模拟器和6.0模拟器上对此进行了测试……对于#2,如果您在运行模拟器的任何设备(Macbook或其他Macs[或Hackintosh])上更改系统时钟,它在模拟器中工作。我已经在5.1模拟器和6.0模拟器上进行了测试。。。