0

I'm working with the EventKit Framework. It is working almost perfect but I have still some issues. When I push my on an Event, it goes to the details of that Event. It shows correctly the details and I can also edit and save it. The problem is with the navigation bar.

It shows the titles inside the navigation bar.These titles are Event Details and Edit. Also it is not showing a backbutton, to go back to my calendar. What I also should mention is that I'm using the Kal Calendar framework.

I'm pushing to de detailsViewController like this.

 Appointment *appointment = [dataSource appointmentAtIndexPath:indexPath];

    // Upon selecting an event, create an EKEventViewController to display the event.
    self.detailViewController = [[EKEventViewController alloc] initWithNibName:nil bundle:nil];
    self.detailViewController.title = @"";
    detailViewController.event = appointment.event;

    // Allow event editing.
    detailViewController.allowsEditing = YES;

   [calendar.navigationController pushViewController:detailViewController animated:YES];

And this is how my delegate looks like

// Overriding EKEventEditViewDelegate method to update event store according to user actions.
- (void)eventEditViewController:(EKEventEditViewController *)controller
          didCompleteWithAction:(EKEventEditViewAction)action {

    NSError *error = nil;
    EKEvent *thisEvent = controller.event;
    controller.title = @"";
    switch (action) {
        case EKEventEditViewActionCanceled:
            // Edit action canceled, do nothing.
            break;

        case EKEventEditViewActionSaved:
            // When user hit "Done" button, save the newly created event to the event store,
            // and reload table view.
            // If the new event is being added to the default calendar, then update its
            // eventsList.
            if (self.defaultCalendar ==  thisEvent.calendar) {
                [self.eventsList addObject:thisEvent];
            }
            [controller.eventStore saveEvent:controller.event span:EKSpanThisEvent error:&error];
            //[calendar reloadData];
            break;

        case EKEventEditViewActionDeleted:
            // When deleting an event, remove the event from the event store,
            // and reload table view.
            // If deleting an event from the currenly default calendar, then update its
            // eventsList.
            if (self.defaultCalendar ==  thisEvent.calendar) {
                [self.eventsList removeObject:thisEvent];
            }
            [controller.eventStore removeEvent:thisEvent span:EKSpanThisEvent error:&error];
            //[calendar reloadData];
            break;

        default:
            break;
    }
    // Dismiss the modal view controller
    [controller dismissModalViewControllerAnimated:YES];

}


// Set the calendar edited by EKEventEditViewController to our chosen calendar - the default calendar.
- (EKCalendar *)eventEditViewControllerDefaultCalendarForNewEvents:(EKEventEditViewController *)controller {
    EKCalendar *calendarForEdit = self.defaultCalendar;
    return calendarForEdit;
}
4

2 回答 2

0

我想出了这个解决方案:

EKEventEditViewController * controller = [[EKEventEditViewController alloc] init];
    controller.eventStore = self.eventStore;
    controller.event = result;
    controller.title = @"";
    controller.navigationItem.title = @"";
    controller.navigationItem.titleView = [UIView new];
    NSArray * array =controller.navigationBar.items;
    UINavigationItem * titleItem = array.firstObject;
    titleItem.title = @"";
    controller.editViewDelegate = (id)self;
    [self presentViewController:controller animated:YES completion:NULL];

EKEventEditViewController没有嵌入到导航控制器中,它有自己的UINavigationBar,如果Apple将来更改它并将其嵌入到导航控制器中,我会保留导航项。

于 2015-02-11T16:04:48.007 回答
0

我认为您已在情节提要或 nib 文件中添加了导航项。去掉它。

制作self.title=nil;self.title=@"";

于 2013-02-07T08:51:31.127 回答