Search code examples
iphoneios6container-view

How to use a Button in Container View's Navigation Controller to go back to last view


Hi I am a newbie in iOS

In my project I didn't want to use a Navigation Bar because of the tint effect, so I used a container view to create something similar except for the back button I used an image with a button on the back.

I have used a Container View(connected to a Navigation Controller) to include a label and a button with an image on top of that button. I want the view to go back to the previous view when I click the button (the one inside the container view's navigation controller). I tried the usual [self.navigationController popViewControllerAnimated:YES]; but with no result. How do I execute this task?


Solution

  • If you are using

    [self presentViewController:yourVC animated:YES completion:nil];
    

    to present your View Controller, then you should use

    [self dismissViewControllerAnimated:YES completion:nil];
    

    to dismiss your present View Controller and to go back to the last View Controller.