在EKEventEditViewController中初始化事件

时间:2010-10-12 09:08:20

标签: iphone

我的代码正在关注

EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];


// set the addController's event store to the current event store.
addController.eventStore = self.eventStore;

// present EventsAddViewController as a modal view controller
[self presentModalViewController:addController animated:YES];

addController.editViewDelegate = self;
[addController release];

它将出现新事件ViewController。我想在EKEventEditViewController中初始化标题和注释。

1 个答案:

答案 0 :(得分:16)

我找到了办法。

EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
event.startDate = event_date;
event.endDate   = event_date;
event.notes=event_note;


EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];


// set the addController's event store to the current event store.
addController.eventStore = eventStore;
addController.event=event;

// present EventsAddViewController as a modal view controller
[parent presentModalViewController:addController animated:YES];

addController.editViewDelegate = self;
[addController release];