0
在事件開始時間之前,事件已成功添加,警報的播放時間爲10秒(用於測試目的)。問題在於報警觸發器(iPhone上的UIAlertView顯示),但消失時間不到一秒鐘。很奇怪......EKEvent警報AlertView在不到一秒鐘內消失
可能是什麼問題?
代碼:
- (IBAction)addEvent:(id)sender {
EKEventStore *eventStore = [[EKEventStore alloc] init];
if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])
{
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)
{
EKEvent *anEvent = [EKEvent eventWithEventStore:eventStore];
anEvent.calendar = eventStore.defaultCalendarForNewEvents;
anEvent.title = self.eventNameTextField.text;
NSDate *date = self.datePicker.date;
anEvent.startDate = date;
anEvent.endDate = date;
NSMutableArray *myAlarmsArray = [[NSMutableArray alloc] init];
EKAlarm *alarm1 = [EKAlarm alarmWithRelativeOffset:-10];
[myAlarmsArray addObject:alarm1];
anEvent.alarms = myAlarmsArray;
NSError *eventError;
[eventStore saveEvent:anEvent span:EKSpanThisEvent error:&eventError];
}];
}
}