When I click the table row, go back to previous view without clicking back button.
I try
[self.navigationController dismissModalViewControllerAnimated:YES];
it's not working. How to dismiss pushViewController ?
dismissModalViewControllerAnimated is used to dismiss a Modal View Controller. These are the view controllers that slide up from the bottom of the screen. An example would be when you tap the button to compose a new email in the Mail app.
If you want the navigation controller to pop back to the previous view controller try using
[self.navigationController popViewControllerAnimated:YES];
Here's a link to the documentation for UINavigationController
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UINavigationController_Class/
[self.navigationController popViewController:YES]
With that line you are dismissing a modal view. That is not the same thing as popping controllers from the navigation controller stack.
You should instead do this:
[self.navigationController popViewControllerAnimated:YES];
This will pop the top controller.
Here is a link to the documentation.
Related
I have a UIView (with identifierSplashScreen) which basically acts as a introduction view and displays a small animation. once the animation is completed i want the view to display a tabbar view which here in after will be the main view. no data of any kind is passed on from the first UIView to the second UIView(with identifier HomeScreen). I have seen most examples where the
secondViewController *svc = [self.storyboard instantiateViewControllerWithIdentifier:#"HomeScreen"];
[self.navigationController pushViewController:svc animated:YES];
but this Pushes the view controller and a navigation bar with a back button appears which I dont want. Also I am never going to Return to the Splash Screen. it would be great if one of you could offer any help.
Iam a biggener and not a expert iOS programeer, so a simple code example will be of great help.
Instead of pushing onto the navigation stack why not replace the stack?
eg.
[self.navigationController setViewControllers:#[svc] animated:NO]
You can do a push segue and not have a navigation bar... Select your navigation controller and on the 4th tab on the right uncheck "Show Navigation Bar"
I need to make a button to dismiss the child view controller from a pushViewController. The action is exactly like the left (back) button on the top navigation bar.
How can I dismiss a pushViewController? Which method should I use ?
Thanks.
UINavigationController's popViewControllerAnimated: method should do it.
In my case where [self performSegueWithIdentifier:#"showAllContacts" sender:self]; pushes a new ViewController, in order to close(dismiss) that view controller which has been pushed I use:
[self.navigationController popViewControllerAnimated:YES];
This is called for a custom button which I added to the navigation bar!
I'm trying to implement a navigation controller with some hierarchical views. I want to use a regular UIViewController to present choices for drilling down, I don't want to use the navigation bar - I want to have my own, custom buttons for returning back up a level.
I see examples like:
[[self navigationController] pushViewController:nextViewController animated:YES];
and my questions are these: Is navigationController a property of all UIViewControllers? Can I refer to self.navigationController regardless of the view that's on the stack? If I'm at an arbitrary view, can I have a button action that contains something like [self.navigationController popToRootViewController animated:YES];
Each view I present will need a button to return to the previous view, or to the root view, depending on the situation. I want to create that button in each view controller and control which view in the stack it returns to. Am I on the right track?
Is navigationController a property of all UIViewControllers?
Yes.
Can I refer to self.navigationController regardless of the view that's on the stack?
Every UIViewController on the UINavigationController's stack will return the UINavigationController object when calling navigationController on it.
If I'm at an arbitrary view, can I have a button action that contains something like [self.navigationController popToRootViewControllerAnimated:YES];
Yes. popToRootViewControllerAnimated: will take the user to the root UIViewController for the UINavigationController, and you can use [self.navigationController popViewControllerAnimated:YES]; to just pop off the top UIViewController. This last one does the same as tapping the Back UIBarButtonItem.
Am I on the right track?
Yes :)
I have a viewcontroller, and I would like to display a modal view controller with :
presentModalViewController when a user finished picking an image.
The modal view controller is working fine when I call it from a button in my main view.
But when I call it from didfinishpickingimage callback nothing happens.
Thanks.
Try
[picker dismissModalViewControllerAnimated:NO];
before
[self presentModalViewController:MY_VIEW_CONTROLLER animated:YES];
Note the animated variable
I had a similar issue. I decided to push the view controller I wanted to display after selecting an image onto my navigation controller instead of trying to present a modal view controller. It has the same effect as presenting a modal.
So I just did:
[self.navigationController pushViewController:MY_VIEW_CONTROLLER animated:YES];
I will try to explain myself as best as possible, I know the title does not say much. Basically i have 4 Navigation Controllers embedded in Tab Bar Controller.
What I want to do is have one of this Navigation Controllers push a new Navigation Controller embeded in aTab Bar Controller dismissing the original Tab Bar Controller. When the user clicks the back Button on the Navigation Controller the original Tab Bar Controller is called.
I tried simply pushing the new Tab Bar Controller in the Navigation Controller, but of course i get now 2 tab bars in my view. At the moment what I am doing is having the navigation controller present my new Tab Bar Controller as a modal View and it works Ok. But I do not have the back button in the Navigation Controller so at the moment I just dismiss my Modal View, which I guess is kinda the same.
I have this in code:
myTabBarController = [[UITabBarController alloc] init];
myTabBarController.viewControllers = [NSArray arrayWithObjects:myNewsNavController, mostPopularController, myAboutNavController, nil];
Where myNewsNavController is Navigation Controller containing a View Controller linked to a TableView then when the user tabs the accesoryButton it presents the modal Controller at the moment.
But I think the user experience would be better if there was a back button instead.
So how can I dismiss the Tab Controller? and then when dismissing the modal view have it back again?. Any help will be Greatly appreciated. Thank you.
-Oscar
I'm not sure exactly what you want, but have you tried setting
myViewController.hidesBottomBarWhenPushed = YES
?
MYViewController *controller = ...;
controller.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:controller animated:YES];
You have to set hidesBottomBarWhenPushed = YES on the controller you are going to push into the view...