Eliminates viewer rejection viewViewControllerAnimated ()

I am using xcode 6. I have a Cancel button in my storyboard, when I click on it, I want to reject my view controller and return to where I come from. Therefore, in my storyboard, I connect the cancel button to my view controller using "Touch up" for my handleCancel method.

When I touch the button, I see that "handleCancel" is being called. I see the debug printfs that I put. But it does not reject my current controller.

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

Could you tell me what else I am missing?

Thanks.

+5
source share
1 answer

What is the current controller class? UIViewController? UINavigationController? Etc. What was the class of the representing controller? Finally, what type did you use? If you are not sure, check the connection inspector in the storyboard. Based on these answers there will be various methods.

For example, if this is a push segment in a UINavigationController, you should view the view:

 self.navigationController?.popViewControllerAnimated(true) 

Any ways, let us know.

+14
source

Source: https://habr.com/ru/post/1203089/


All Articles