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];
}
楽しみ!
マーク