我是新的EKEventKit,我正在嘗試使用EKEvent在日曆中創建事件。它工作正常,但保存事件後,當我再次檢查它提前一天的事件日期。日曆中的事件日期在保存後一天設置
我在這裏輸出我的代碼。請看看
EKEventStore *eventStore = [[EKEventStore alloc]init];
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
// set Event Title and Notes
event.title = @"My New Event";
event.notes = @"New event notes are added by azeem";
// set Event Start and End date here
NSLog(@"before saving Date: %@",[NSDate date]);
event.startDate = [NSDate date];
event.endDate =[NSDate date];
// set Evet other Properties here
event.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
event.calendar = [eventStore defaultCalendarForNewEvents];
event.allDay = YES;
[eventStore saveEvent:event span:EKSpanThisEvent error:&error];
NSLog(@"After saving Date: %@",event.startDate);
OUTPUT ::
Before Saving Date : 2013-04-10 08:00:40 +0000
After Saving Date: 2013-04-09 00:00:00 +0000
我們可以看到這裏有前1天。但它們應該是一樣的。
我希望我對我的問題非常清楚,但如果有任何問題,可以問我。
感謝預期。