I'm adding a view controller programatically via a navigation controller as I need to access the navigation bar whilst the controller is being presented.
I'm currently doing this via the method below however I need to be able to remove the reference to the view controller when the user taps the dismiss button.
let settingsController = storyboard?.instantiateViewController(withIdentifier: "SettingsController") as! SettingsController
settingsController.view.alpha = 0
settingsController.view.transform = CGAffineTransform(translationX: 0, y: self.view.frame.height)
self.view.addSubview(settingsController.view)
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
print(self.view.frame.height)
settingsController.view.transform = CGAffineTransform(translationX: 0, y: self.view.frame.height - 142)
settingsController.view.alpha = 1
}, completion: nil)
Is there a way I can do this as the current self.dismiss or self.popViewController doesn't work?
Thanks
UPDATE
I tried to implement this solution using the standard perform segue (below) by presenting modally option as I need to keep the navigation bar active. The settings controller height is less than the view frame. This didn't work so I'm trying the above method.
self.definesPresentationContext = true
self.modalPresentationStyle = .overCurrentContext
self.modalTransitionStyle = .coverVertical
self.performSegue(withIdentifier: "SettingsSegue", sender: nil)
When I call the settings controller up and dismiss another settings controller gets added resulting in multiple settings controllers. This is my issue.