Skie Skie - 7 months ago 10
Swift Question

Correctly closing of new ViewController pages

Help me please with my ViewControllers closing.
Im open new ViewController ("SettingsPage") with this code:

settingClass = storyboard?.instantiateViewControllerWithIdentifier("SettingsPage") as! SettingsClass
settingClass.modalPresentationStyle = .OverFullScreen
settingClass.modalTransitionStyle = .CrossDissolve
self.presentViewController(settingClass, animated: true, completion: nil)


Then im need to go back (close SettingsPage) and when im used this method ill get doubles of MainView

mainClass = storyboard?.instantiateViewControllerWithIdentifier("MainView") as! ViewController
mainClass.modalTransitionStyle = .CrossDissolve
self.presentViewController(mainClass, animated: true, completion: nil)


how to correctly close new ViewController ("SettingsPage") witch open like .OverFullScreen, and go back to my MainView?

Answer

Try to close it like this

mainClass.dismissViewControllerAnimated(true, completion: {});