Open jmcazaux opened 7 years ago
Hi,
I am not sure what kind of navigation stack you are using, but if you have a sliding menu or tab bar it shouldn't be a problem to dismiss settings view controller. Otherwise, you would have to hook up a custom button to SwiftySettingsController which would dismiss the controller. Unfortunatelly this is not currently supported out of box, but you may achieve something similar by embedding SwiftySettingsViewController in another ViewController which provides such a button.
Hi @jmcazaux,
I used this code:
(viewControllers.first as? UINavigationController)?.navigationBar.items?.first?.rightBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .done, target: self, action: #selector(dismissVC))
@hintoz Wish i found your answer couple of hours ago ! I was trying to add the button to leftBarButtonItem
with no hope. Now it worked when I added to the rightBarButtonItem
@hintoz @iballan I'm new to iOS programming, where should I put this line to dismiss the setting view?
(viewControllers.first as? UINavigationController)?.navigationBar.items?.first?.rightBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .done, target: self, action: #selector(dismissVC))
@xzhub In the viewDidLoad method for example.
Thanks, now it works! For newbies like me, please note that you have to add the dismissVC function in ViewController as well.
class ViewController: SwiftySettingsViewController {
var storage = Storage()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
loadSettingsTopDown()
(viewControllers.first as? UINavigationController)?.navigationBar.items?.first?.rightBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .done, target: self, action: #selector(dismissVC))
}
@IBAction func dismissVC(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
... ...
Hi Tomasz,
I tried to integrate SwifySettings to my app and made a few changes to improve UI (will submit a PR).
In my UI, the user accesses the settings from an app menu, then they lan on the SwiftySettings controller...
Then I did not find a way to bring them back to the app (dismiss the settings controller).
How would you achieve this?