I am going to use an UINavigationController to keep track of all the views the user visits. This is all well and good except that I do not want the navigation bar to appear on the first view. Is it possible not to show the navigation bar on the first view?
Thanks!
sure, you can use - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated on the navigation controller, when you want to hide it and then use it again to display it.
so if you are on a view controller that is the root for the UINavigationController, you might want to call it in the viewWillAppear: method:
[self.navigationController setNavigationBarHidden:YES animated:NO];
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 am using a UINavigationController to slide from a UITableViewController to another view. In that second view I have created a custom "Back" button which is attached to an action.
What code do I use to return to dismiss the current view and slide back to my first view? I need something that is the equivalent to [super dismissModalViewControllerAnimated:true]; but obviously this is not a modal view.
Thanks.
Look at one of the following three methods on your navigation controller:
popViewControllerAnimated:
popToRootViewControllerAnimated:
popToViewController:animated:
Depending on how you want to handle it of course. Generally one just uses the first method to go back to the last view (the one that pushed your current view onto the navigation stack).
Use popToRootViewControllerAnimated method in UINavigationController:
[self.navigationController popToRootViewControllerAnimated:animated];
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'm working on iphone app which will show 4 buttons in first view. on click of a button, it will load a new view with navigation controller. this navigation controller view allows to travel upto 11 sub views. in 11th sub view, i've a reset button. on click of reset button, i've to go back to navigation controllers first view without traversing all the 11 views? is it possible to achieve it? if yes how? if no, what can be the solution?
You can also use the:
[self.navigationController popToRootViewControllerAnimated:YES];
u can use [self.navigationController popToViewController:objFirstViewController animated:YES] in the 11th view when you want to pop directly to the first view.
And if you are sure that you have to move to the first view and it is a rootviewcontroller then you can directly use
[self.navigationController popToRootViewControllerAnimated:YES];
Happy Coding..
I know that a UINavigationController has good view pushing methods. But let's say that I don't want to use a UINavigationController because I don't want the bar on the top of the screen. Is there a specific way to push and pop views as I want them?
Also, when should I use presentModalViewController and when shouldn't I?
Thanks,
Anthony
UPDATE:
What about adding a subview to a view?
You can always use
[navigationController setNavigationBarHidden:YES animated:NO];
or set it via IB.
If you have a navigation structure of depth 2 or more, it is always right to use a UINavigationController object but when you have only two related views where one of them supplements the other, you can use a modal view controller.