Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dismissViewControllerAnimated() does not dismiss view controller

Tags:

ios

swift

I am using xcode 6. I have a 'Cancel' button in my storyboard, when I click it, I want to dismiss my view controller and go back to where I come from. So in my storyboard, I wire the cancel button to my View Controller with 'Touch up' to my 'handleCancel' method.

When I touch the button, I see 'handleCancel' is being called. I see the debug printfs I put it. But it does not dismiss my current view controller.

@IBAction func handleCancel(sender: AnyObject) {      
    println("Calling handle Cancel")
    self.dismissViewControllerAnimated(false, completion: nil)
}

Can you please tell me what else I am missing?

Thank you.

like image 698
hap497 Avatar asked Sep 21 '14 18:09

hap497


1 Answers

What is the current controller class? UIViewController? UINavigationController? Etc. What was the class of the presenting controller? Finally, what kind of segue did you use? Check the connections inspector in storyboard if unsure. There will be different techniques based on these answers.

For example, if this is a push segue in a UINavigationController you would pop the view with:

self.navigationController?.popViewControllerAnimated(true)

Any ways, let us know.

like image 179
Steve Rosenberg Avatar answered Oct 28 '22 22:10

Steve Rosenberg