【问题标题】:EKEditviewController keeps showing the title in the navigationbarEKEdit viewController 一直在导航栏中显示标题
【发布时间】:2013-02-07 08:15:18
【问题描述】:

我正在使用EventKit Framework。它工作得几乎完美,但我仍然有一些问题。当我推送一个事件时,它会转到该事件的详细信息。它正确显示了详细信息,我也可以编辑和保存它。问题出在导航栏上。

它在导航栏中显示标题。这些标题是事件详细信息和编辑。它也没有显示返回按钮,返回我的日历。我还应该提到的是,我正在使用 Kal Calendar 框架。

我正在像这样推送到de detailsViewController。

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

这就是我的代表的样子

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

【问题讨论】:

    标签: iphone ios objective-c eventkit ekeventkit


    【解决方案1】:

    我想出了这个解决方案:

    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 将来更改它并将其嵌入到导航控制器中,我会保留导航项。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 我无法删除它。我认为这是因为我嵌入了导航控制器。
      • @StefGeelen:为什么你不能删除它
      • 因为一旦您将 VC 嵌入到导航控制器中。它会自动将其添加到您的 VC。
      • 如果你有外部添加,那么你可以删除它。如果你没有外部添加,那么它不需要
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-23
      • 1970-01-01
      • 2013-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多