Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.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的repeatInterval设置为每两天一次?_Ios_Objective C_Uilocalnotification_Nscalendar - Fatal编程技术网

Ios 如何将UILocalNotification的repeatInterval设置为每两天一次?

Ios 如何将UILocalNotification的repeatInterval设置为每两天一次?,ios,objective-c,uilocalnotification,nscalendar,Ios,Objective C,Uilocalnotification,Nscalendar,如何将UILocalNotification设置为每两天、每三天重复一次,等等。。。?如果不使用默认的NSCalendarUnits?您不能重复,在两天内,LocalNotification只允许4次重复间隔 以天、周、月或年为单位 这是一个枚举值,您无法自定义它,我看到的唯一解决方案是计算时差,比较两天时间,然后再次尝试设置它首先,我们必须设置NSDate,我们将在该日期发出第一个本地通知。 调用通知后,设置下一个通知 NSDate *afterTwoDays = [[NSDate date]

如何将UILocalNotification设置为每两天、每三天重复一次,等等。。。?如果不使用默认的NSCalendarUnits?

您不能重复,在两天内,LocalNotification只允许4次重复间隔

以天、周、月或年为单位


这是一个枚举值,您无法自定义它,我看到的唯一解决方案是计算时差,比较两天时间,然后再次尝试设置它

首先,我们必须设置NSDate,我们将在该日期发出第一个本地通知。 调用通知后,设置下一个通知

NSDate *afterTwoDays = [[NSDate date] dateByAddingTimeInterval:+2*24*60*60];
设置所需的参数:

UILocalNotification *localNotification=[[UILocalNotification alloc]init];
localNotification.fireDate =afterTwoDays;
localNotification.alertBody = @"Body";
localNotification.alertAction = @"Alert";
localNotification.repeatInterval=0;
localNotification.soundName=UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

你不明白这个问题。