0
votes

I've been trying to present and dismiss a view controller programmatically and I keep running into EXC issues.

What is the proper way to present and dismiss a view controller other than using:

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewControllerWithIdentifier("Popup") as UIViewController

    self.presentViewController(vc, animated: true, completion: nil)

and self.dismissViewControllerAnimated(true, completion: nil)

?

So far the app crashes when i run the function: dismissViewControllerAnimated

Please help, thanks!

1
is it got called in UI thread? - Duyen-Hoa
are you dismissing the root view controller? - Louis Tur
@HoaParis Not really sure, I didn't think dispatch was needed for this kinda of UI Updating - springBrd2
@Louis Tur, I'm not sure although, If i dismiss the root view controller i don't know if I can programmatically call it back when I dismiss the foreground viewController. - springBrd2
Can you show your crash log? - Duyen-Hoa

1 Answers

0
votes

Apparently, I had a NSNotification listener in the ViewController which caused the crash.

What I did was take it out and re-did the ViewController to populate the View Controller via a method rather than use a method linked to a NSNotification Listener.