可能重复:
How to add events in iPhone using Event Kit framework
Adding particular date in default calender as an event
我正在制作一个应用程序,我想在我的iPhone应用程序中使用现有的日历事件和日程安排事件。 我还想通过我的应用程序编辑事件..
提前致谢...
答案 0 :(得分:1)
在头文件中导入 EventKitUI / EventKitUI.h,EventKit / EventKit.h 框架。这是将事件添加到默认iPhone日历的代码
-(IBAction) addEvent:(id)sender
{
EKEventStore *eventStore = [[[EKEventStore alloc] init] autorelease];
EKEvent *events = [EKEvent eventWithEventStore:eventStore];
events.title = @"Title";
events.notes = @"Description";
events.location = @"Location";
events.startDate = [NSDate date];
events.endDate = [NSDate date];
events.availability = EKEventAvailabilityFree;
[events setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:events span:EKSpanThisEvent error:&err];
NSLog(@"Error From iCal : %@", [err description]);
}
然后,您可以使用EKEventEditViewController
EKEventEditViewController *editViewController = [[EKEventEditViewController alloc] init];
editViewController.editViewDelegate = self;
editViewController.event = event3;
editViewController.eventStore = eventStore1;
[self presentModalViewController:editViewController animated:YES];
希望这有帮助
答案 1 :(得分:0)
参考EventKit框架来完成这些。 Apple文档是here。