ios - 每日 UILocalNotification 触发不止一次

标签 ios iphone nsdate uilocalnotification

你好,我面临一个奇怪的问题。实际上,我想安排每天上午 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/

相关文章:

ios - 如何在调用 UIImagePickerController 后隐藏状态栏?

ios - 根据 UICollectionView Cell 更改 UINavigationbar 标题

iphone - 为什么我的录音无法播放? (iPhone SDK)

ios - 核心数据希望我的谓词参数为NSNumber和NSDate

ios - 如何在 iOS 中显示当前和前 6 个月的年份?

ios - 当应用程序处于引导访问模式时,CLLocation 管理器未更新

ios - Xcode - 在其他 View 中按下按钮时更新标签文本

iphone - 如何应对界面方向变化?

iphone - 为什么除非我首先访问父类的描述,否则 NSManagedObject 关系对象无法正确加载?

xcode - 如何将字符串转换为具有无关字符的 NSDate (swift)?