3

EKEventEditViewControllerはNavControllerへのプッシュをサポートしていませんか?添付のコードとエラーを参照してください。

EKEventEditViewControllerをモーダルに正常に表示できますが、navコントローラーを介してプッシュしようとすると、次のエラーが発生します。

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'

コードは次のとおりです。

EKEventEditViewController *addController = [[[EKEventEditViewController alloc] initWithNibName:nil bundle:nil] autorelease];
addController.eventStore = self.eventStore;
addController.editViewDelegate = self;

[self.navigationController pushViewController:addController animated:TRUE];   // ERROR HERE
4

3 に答える 3

3

EKEventEditViewControllerはUINavigationControllerのサブクラスであるため、別のUINavigationControllerにプッシュすることはできません。

EKEventEditViewControllerはモーダルで表示する必要があります。

EKEventEditViewControllerクラス参照

于 2011-11-03T07:01:47.453 に答える
0

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];
}

楽しみ!

マーク

于 2012-05-17T18:30:37.987 に答える
0

将来の読者のために:

EKEventEditViewControllerはUINavigationControllerであるため、次のように言うことができます。

EKEventEditViewController *controller = [[EKEventEditViewController alloc] init];

// Set your properties here

[self.navigationController pushViewController:controller.viewControllers[0] animated:YES];

これは私にとってはうまくいきますが、Appleのためにこれができるかどうかはわかりません。

于 2013-09-10T16:27:47.830 に答える