你好,我面临一个奇怪的问题。实际上,我想安排每天上午 8:00 发出通知(每天一次)。下面是我用于安排每日通知的代码。
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"HH:mm"];
NSDate *date = [[NSDate alloc] init];
date = [formatter dateFromString:@"08:00"];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = date;
localNotification.timeZone=[NSTimeZone defaultTimeZone];
localNotification.alertBody = @"You just received a local notification";
localNotification.alertAction = @"View Details";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.repeatInterval = NSDayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[formatter release];
[date release];
我的问题是,我收到 2 条本地通知。一场在上午 8:00,另一场在上午 10:00。为什么我会在上午 10:00 收到通知。我只安排在上午 8:00。我知道 UILocalNotification 库在大多数苹果设备上还有一些其他奇怪的问题/错误。我只是想确认我的代码中是否存在错误,或者这是 UILocalNotification 库的奇怪行为。我不知道为什么 Apple 不致力于解决许多开发者报告的有关 UILocalNotification 的问题。
注意:我使用的是 Xcode 4.6 和 iOS 6.1
最佳答案
这将是 BEST链接以获得答案。
关于ios - 每日 UILocalNotification 触发不止一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19762936/