Search code examples
iosswiftinappsettingskit

InAppSettingsKit Done button does not show up on view controller


I am trying to use InAppSettingsKit from my Swift app (via Swift package dependency to version 3.3.3), and I would like to be able to use the settingsViewControllerDidEnd delegate callback to determine when the user has dismissed the settings dialog, so that I can check for certain conditions that may require additional actions on the user's part.

The Done button was showing up if I pushed the view controller onto a navigation controller, but the code indicates that this method will not fire the Done button delegate callback, so I have been trying to use the present method to show the view controller.

Here is the code that I am using to instantiate and present the settings view controller:

func authenticationSettings(alert: UIAlertAction!) {
    let viewController = IASKAppSettingsViewController()
    viewController.delegate = self
    self.present(viewController, animated: true, completion: nil)
}

And here is what I get, notice no Done button:

enter image description here

I have tried this card method of presenting, and also the full screen method, with no avail.

I tried stepping into the Objective-C code and and from what I could tell, the UIBarButtonItem navigation item was being created and added. Anyone have any ideas on what to try next?


Solution

  • As you may have noticed in the source code, UIBarButtonItem gets added on navigationItem. This item is used only if view controller is part of a navigation controller stack

    When you're presenting a new view controller modally it doesn't have a navigation controller in the stack, so to make it work you need to wrap your controller with a UINavigationController:

    func authenticationSettings(alert: UIAlertAction!) {
        let viewController = IASKAppSettingsViewController()
        viewController.delegate = self
        let navigationController = UINavigationController(rootViewController: viewController)
        self.present(navigationController, animated: true, completion: nil)
    }