如果您正在寻找一些代码来启动 iPad-with-popover 实现:
EKEventStore *eventStore [[EKEventStore alloc] init];
EKEventEditViewController *eventController = [[EKEventEditViewController alloc] init];
eventController.editViewDelegate = self;
eventController.eventStore = eventStore;
EKEvent *event = [EKEvent eventWithEventStore: eventStore];
event.title = @"New Event";
event.startDate = [[NSDate alloc] init];
event.endDate = [[NSDate alloc] initWithTimeInterval: 60 * 60 sinceDate: event.startDate];
eventController.event = event;
/* You can add EKEventEditViewController directly to the popover -- this had me baffled for _hours_ */
popover = [[UIPopoverController alloc] initWithContentViewController: eventController];
当用户完成或取消事件编辑时,您还需要包含此委托方法来执行您需要执行的任何操作:
- (void) eventEditViewController: (EKEventEditViewController *)controller didCompleteWithAction: (EKEventEditViewAction)action
{
EKEvent *thisEvent = controller.event;
switch (action) {
case EKEventEditViewActionCanceled:
NSLog(@"Canceled action");
break;
case EKEventEditViewActionSaved:
NSLog(@"Saved action: %@", thisEvent.startDate);
break;
case EKEventEditViewActionDeleted:
NSLog(@"Deleted action");
break;
default:
break;
}
[popover dismissPopoverAnimated: YES];
}
享受!
标记