我正在尝试使用EventKit.framework在iPhone日历中保存事件。它保存完美,但我想将警报设置为“NONE”,但默认情况下需要'30分钟'作为警报。我怎么解决这个问题?这是我在iPhone日历中保存事件的代码
if ([appDelegate.objEvent.event_alert intValue]==0) {
alarm1 = [EKAlarm alarmWithRelativeOffset:0];
}
else if ([appDelegate.objEvent.event_alert intValue]==1) {
alarm1 = [EKAlarm alarmWithRelativeOffset:-5];
}
else if ([appDelegate.objEvent.event_alert intValue]==2) {
alarm1 = [EKAlarm alarmWithRelativeOffset:-300];
}
else if ([appDelegate.objEvent.event_alert intValue]==3) {
alarm1 = [EKAlarm alarmWithRelativeOffset:-900];
}
else if ([appDelegate.objEvent.event_alert intValue]==4) {
alarm1 = [EKAlarm alarmWithRelativeOffset:-1800];
}
else if ([appDelegate.objEvent.event_alert intValue]==5) {
alarm1 = [EKAlarm alarmWithRelativeOffset:-3600];
}
else if ([appDelegate.objEvent.event_alert intValue]==6) {
alarm1 = [EKAlarm alarmWithRelativeOffset:-7200];
}
else if ([appDelegate.objEvent.event_alert intValue]==7) {
alarm1 = [EKAlarm alarmWithRelativeOffset:-86400];
}
else if ([appDelegate.objEvent.event_alert intValue]==8) {//B4 2 days
alarm1 = [EKAlarm alarmWithRelativeOffset:-172800];
}
NSMutableArray *myAlarmsArray = [[NSMutableArray alloc] init];
// [myAlarmsArray addObject:alarm1];
// event.alarms = myAlarmsArray;
// [myAlarmsArray release];
if ([appDelegate.objEvent.event_alert intValue]!=0)
{
[myAlarmsArray addObject:alarm1];
event.alarms = myAlarmsArray;
}
else
{
// [myAlarmsArray addObject:nil];
// event.alarms = nil;
}
答案 0 :(得分:0)
根据文档,如果您想要触发警报,正如您所说的那样,我认为您的意思是在事件发生的确切时间触发,您将使用以下代码
[EKAlarm alarmWithAbsoluteDate:date];