Search code examples
swiftioswift3jtapplecalendar

ViewController Delegate Doesn't Get Invoked


I am trying to implement an external module called JTAppleCalendar in my app and load a calendar when a user taps on a button. While the view associated with the external calendar loads properly, the delegate method for the viewcontroller associated with the view doesn't get invoked; thus, no calendar shows up. Tried debugging and figuring out why this happens, no luck. I have the entire project here: https://github.com/cooderatgit/CalendarApp/tree/master/KataNews

Problem code is in the CalendarViewController.swift. The associated xib is Calendar.xib. The delegate function is calendar(). ViewController.swift manages the main storyboard views.

The tutorial that I am following for setting up the calendar: https://patchthecode.github.io/MainTutorial/


Solution

  • The problem is related to the way you are presenting CalendarViewController.

    In line 30 of ViewController.swift you only add the CalendarViewController's view as a subview of the navigationController.

    A better way to do this could be:

    self.navigationController?.present(overlayView, animated: true)
    

    This should properly present the view controller.