Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UILocalNotification接收通知,重复间隔为NSYearCalendarUnit(将火灾日期移动到下一个火灾日期)_Ios_Uilocalnotification - Fatal编程技术网

Ios UILocalNotification接收通知,重复间隔为NSYearCalendarUnit(将火灾日期移动到下一个火灾日期)

Ios UILocalNotification接收通知,重复间隔为NSYearCalendarUnit(将火灾日期移动到下一个火灾日期),ios,uilocalnotification,Ios,Uilocalnotification,我将通知的repeatInterval设置为NSYearCalendarUnit。 当我收到通知时,我看到我记录的通知信息: fire date = Tuesday, 13 May, 2014... next fire date = Wednesday, 13 May, 2015 然后我取消了通知,认为它将把火灾日期移到2015年5月13日 [application cancelLocalNotification:locationNotification]; 但它没有。。。它确实取消了通知

我将通知的repeatInterval设置为NSYearCalendarUnit。 当我收到通知时,我看到我记录的通知信息:

fire date = Tuesday, 13 May, 2014... next fire date = Wednesday, 13 May, 2015
然后我取消了通知,认为它将把火灾日期移到2015年5月13日

[application cancelLocalNotification:locationNotification];
但它没有。。。它确实取消了通知

但当我没有取消通知时,通知会保留,但我的解雇日期保持不变,我希望它移到2015年,下一个解雇日期移到2016年

fire date = Tuesday, 13 May, 2014... next fire date = Wednesday, 13 May, 2015

您应该更新通知的火灾日期

试试这个:

// Maybe in your code you don't need this, but I write it anyway
[application cancelLocalNotification:locationNotification];

// This will create a new date one year past the current notification fire date
NSDateComponents * components = [[NSDateComponents alloc] init];
components.year = 1;
NSDate * newDate = [[NSCalendar currentCalendar] dateByAddingComponents:components toDate:localNotification.fireDate options:kNilOptions];

// Now you can update the localNotification fire date
localNotification.fireDate = newDate;

// Schedule it. Again, maybe you don't need this in your code
[application scheduleLocalNotification:localNotification];

你是如何检查火灾日期是否保持不变的?我认为通过将你的设备日期改为明年,即2015年5月14日,调试你的应用程序,并检查点火日期是否更改。。。NSArray*通知=[[UIApplication sharedApplication]scheduledLocalNotifications];。。。NSLog(@“通知:%@”,通知);如上所述更改设备日期并再次检查。哈哈,我将设备更改为明年,但我无法再运行我的应用程序,我想因为我的合同将在今年到期。。。真的是因为这个吗?我的意思是,一旦设备日期移到明年,启动日期就会移动?是的,对于调试,您可以将重复间隔设置为较短的时间段,如1分钟1天等,并通过更改设备日期/启动日期更改时间进行检查。