每日UILocalNotification不止一次发射

时间:2013-11-04 06:52:57

标签: 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点安排它。我知道UILocalNotification库在大多数苹果设备上都有一些其他奇怪的问题/错误。我只是想确认我的代码中是否存在错误,或者它是UILocalNotification Library的奇怪行为。我不知道为什么Apple没有解决许多开发人员关于UILocalNotification报告的问题。

注意:我使用的是Xcode 4.6和iOS 6.1

1 个答案:

答案 0 :(得分:1)

这是获得答案的BEST链接。

相关问题