Search code examples
objective-cekeventkit

EKEventEditViewController default navigation bar title is not showing


I have this weird issue regarding the EKEventEditViewController which does not display the "Add Event" title in the navigation bar. I use the following code to present it:

[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
    if (!granted) { return; }
    
    __block EKEvent *calEvent = [EKEvent eventWithEventStore:eventStore];
    calEvent.title = self.event.title;
    calEvent.startDate = startDate;
    calEvent.endDate = endDate;
    calEvent.location = self.event.address.title;
    [calEvent setCalendar:[eventStore defaultCalendarForNewEvents]];
    
    __block EKEventEditViewController *eventViewController = [[EKEventEditViewController alloc] init];
    eventViewController.editViewDelegate = self;
    eventViewController.eventStore = eventStore;
    eventViewController.event = calEvent;
    dispatch_async(dispatch_get_main_queue(), ^{
        [self presentViewController:eventViewController animated:YES completion:nil];
    });
}];

The result is this: enter image description here

Any help would be greatly appreciated.


Solution

  • I have no idea why this was happening but it got fixed by itself when I added the following appearance setting in my AppDelegate:

    NSDictionary *barTitleAppearanceDict = @{UITextAttributeFont : [UIFont fontWithName:@"HelveticaNeue" size:22.0]};
    [[UINavigationBar appearance] setTitleTextAttributes:barTitleAppearanceDict];