Question

I have a Master Detail View application. On the detailView I have a welcome screen, and on the tableView I have list of employees. When I click on the employee, call a seperate view on top of DetailView with the below code.

[_dtController.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"OBViewController"] animated:YES];

I can go back from the Navigation bar button, but I have a button on my OBViewController, through which I have to go back. Can anyone tell me how to navigate and go back from a button.

Was it helpful?

Solution

You'll want to take a look at Apple's UINavigationController Class Reference.

Specifically, the below item:

 - (UIViewController *)popViewControllerAnimated:(BOOL)animated

This can be used from any view within a view to get your desired outcome. It's important to note the difference between "push" and "pop" with regards to the UINavigationController hierarchy. To add a view, you push it to the stack. To remove it, you pop it off the stack.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top