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

StackOverflow https://stackoverflow.com/questions/18096518

  •  23-06-2022
  •  | 
  •  

Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

the view which you want to push to connect with UINavigation Controller pls clear that you is your app navigation based app, if not pls add it in App Delegate

ViewController *ViewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:ViewController] autorelease];
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top