EKCalendarChooser toolbar remains

Hi Guys


This issue has popped up since I updated to latest SDKs / started working on iPhone X support.


I show an EKCalendarChooser - and when it disappears the bottom toolbar remains on the screen - obscuring the content of the rest of my app.


This is how I show it:


EKCalendarChooser *calendarChooser = [[EKCalendarChooser alloc]
                                                  initWithSelectionStyle:EKCalendarChooserSelectionStyleMultiple
                                                  displayStyle:EKCalendarChooserDisplayAllCalendars
                                                  eventStore:eventStore];
         
calendarChooser.showsDoneButton = YES;
calendarChooser.showsCancelButton = YES;
calendarChooser.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
calendarChooser.selectedCalendars = syncdCalendars;
calendarChooser.delegate = self;
         
[[self navigationController] pushViewController:calendarChooser animated:YES];

Whether I pop the view controller via the Done button, or hide the buttons and let my nav controller handle it with Back - the toolbar remains in view.


This is the bottom toolbar on the calendar chooser with the Add Calendar and Show All buttons. The buttons disappear but the toolbar stays there for the remainder the life of the app. At least that is what appears to happen - it is possible that the toolbar has also gone and just left a gap.


Does anybody have any ideas on why this may happen?


Many Thanks

Hanks

Replies

Edit: It doesn't appear to be a toolbar - my root view controller seems to have shrank to accomodate the space taken by the EKCalendarChooser minus the toolbar - or at least minus the same height a toolbar occupies. So I have a white gap at the bottom.

Hi Hanks,


I'm having the exact same issue recently and found the following discovering.


It looks like if you use a navigation controller to push the EKCalendarChooser, the toolbar will remain when it pops back (strangely it started to happen to me on 11.4 onwards). Tried the following 2 methods could avoid this issue.


1. Wrap the EKCalendarChooser inside another navigation controller and present it modally instead of push. Everything will be dismissed when you call dismiss on the newly created navigation controller.

let navController = UINavigationController(rootViewController: chooser)
present(navController, animated: true)


2. Subclass EKCalendarChooser and override viewWillAppear to hide the toolbar.
override func viewWillAppear(_ animated: Bool) {
  super.viewWillAppear(animated)
  navigationController?.setToolbarHidden(true, animated: false)
}


I personally go for the 2nd method as I'd like to present the calendar chooser via push / pop instead of modal view. Hope it helps.