0
votes

I have a view controller that shows the details of an object. On this view controller is an "edit" button which shows modally the edition view controller. When I try to dismiss the modally presented view (edit view controller) :

self.dismissViewControllerAnimated(true, completion: nil)

I get the following error and it's presenting my initial viewController instead :

Warning: Attempt to present ≤Deevent.MyEventsVC: 0x7f99b70160a0≥ on ≤Deevent.EventCreationVC: 0x7f99b7238690≥ whose view is not in the window hierarchy!

So what I've tried was to set the root view controller of my view to the view I wanted to go back and present it in the completition of my dismiss. It's working well, but my application is in a Tabbar Controller and now it's not in it anymore. Same for the navigation controller.

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("MyEventsStoryboard") as! MyEventsVC

let appDelegate = (UIApplication.sharedApplication().delegate as AppDelegate)
appDelegate.window?.rootViewController = vc

self.dismissViewControllerAnimated(false, completion: {
                    self.presentViewController(vc, animated: true, completion: nil)
                })

Is there an other approach for presenting viewControllers after dismiss without leaving the Tabbar controller ?

Thanks

1
what are u trying to acheive pls explain a little moreAjay Beniwal
I have a view controller which shows the details of an object. On this view I have an "edit" button which shows the edition view controller modally. When I try to dismiss the edition view controller, I get the error and instead of showing me my details view controller, it shows me my initial (login) view controller.Nicolas Meienberger
share the code where you are presenting view controller modallyAjay Beniwal
It's just a performSegueWithIdentifier : self.performSegueWithIdentifier("editEvent", sender: self)Nicolas Meienberger
For the error that you are getting, have you checked stackoverflow.com/questions/11862883/… or stackoverflow.com/questions/28379327/…Guy Daher

1 Answers

-2
votes

Since you are trying to present the new view controller by calling self.presentViewController after you dismiss self, you get the error. I can offer you a solution if you are using a navigation controller.