my app first viewController is UIViewController.
and when user click button firstView disappear and push UITabViewController
is it possible?
i can't find how to push UITabViewController from UIViewController.
UPDATE sorry, I misread TabVC for UITableViewController. Do you mean UITableViewController or UITabBarController? I'll leave my answer below anyways.
In this instance, it's usually best to have a UITabBarController be the root view object. Although it can be done, it's a messier implementation, in my opinion.
I would in fact make the UITabBarController the root and display the UIViewController modally from that UITabBarController on launch.
The user would be presented with the UIViewController and when they clicked the button, dismiss that modal view, revealing the UITabBarController.
Just use a UINavigationController.
Use the navigation controller to push the tableView as the second level in the hierarchy. As a bonus you'll get the back button for 'free' and you don't have to worry about delegates for getting back to the original UIViewController.
you may try this:
self.tabBarController.selectedViewController
= [self.tabBarController.viewControllers objectAtIndex:2];
it should work because selectedViewController property contains view of selected tab.
First of all you have view controller . And make Second view controller which contain tabbarcontroller . Now just push second view controller . And add tabbarcontroller's view as a subview to second view controller .
Hope you gets it ..
Related
I don't know what I'm doing wrong, but my UITabBar is not showing after a segue. Basically, the hierarchy goes like:
Tabbar > Navigation Controller > View Controller > Navigation Controller > View Controller
I tried removing the second UINavigationController in order to make that transition, the first (blue) UIViewController has a slide up menu (just a basic UIView with buttons, that's Y offset is off the screen, with basic animation) and when a button is clicked, it leads to the appropriate UIViewController. Once the View controller is presented, you no longer see the UITabBar. Basically, the View Controller tops it. I tried changing the segue from modally presented to push, but it doesn't change it. I don't know what I'm doing wrong.
Here's a screenshot of the UIStoryboard to illustrate that better. PS: The UITabBar is not visible on this UIStoryboard, but it's shown in the simulator. I can guarantee that.
UPDATE: Full screen of the storyboard added
Set your hierarchy like:-- Navigation > Tabbar > Navigation Controller > View Controller
When u try to push view controller from tab u set tabbar as navigation and most important thing is set your root view hierarchy.
set your break point where view controller is present and then in debug area "po(navigation cotroller)" it's may be nil.
I,it will help you.
Heirarchy of viewController:- Navigation1 > ViewController1 > Navigation2 > ViewController2.(By the this is not good way to handle this type of hierarchy)
when I push from ViewController1 to ViewController2 it will be present because of now set Navigation2 means ViewController2 set as root view Controller.
But I want to push ViewController1 to ViewController2 I need to change root view controller as ViewController2.
Now when I need to remove Navigation2 at that time change root as ViewController1.so,as per your question you need to change root view controller.
My UIViewController calls a function on my rootViewController which then called popToRootViewControllerAnimated to return the view to the rootController. This all works - great!
Unfortunately the UINavigationItem (toolbar at the top) seems to display a mashup of both the rootViewController and the UIViewController that has just been removed.
What do I need to do? What have I done wrong?
The navigation bar doesn't remember changes that were made to it, so when you push a new controller, the navigation bar is altered to give the title of the new view controller, but it doesn't store what was there for the previous view controller.
You will need to recreate the items in the toolbar each time you come back to the view controller that has custom items.
You might be able to do this on viewWillAppear instead of viewDidLoad. I can't recall exactly, but you should recreate custom controls on navigation toolbar because it does not get preserved when a new view controller is pushed.
It seems that calling popToRootViewController from the rootViewController messes things up. TO rectify this I called the following from within the calling UIViewController
[self.navigationController popViewControllerAnimated:YES];
I have a project based on Xcode's NavigationController template. This template has a navigationController and a RootViewController.
From inside this RootViewController I push a view and this view pushes a third view. Something like:
NavigationController >> RootViewController >> ViewController 1 >> ViewController 2
Now, from ViewController2 I want to access the navigationController and the navigationController.toolbar.
I know that every viewController has the navigationController property but my question do I have to do something when I push a new viewController so this variable (on the view that is being pushed) will have a valid reference to the correct ViewController or all pushed views will always have a valid reference to the navigationController?
The reason for my question is that I am trying to access the navigationController.toolbar, to make it invisible, and I am having no result.
thanks.
You might want to try -[UINavigationController setToolbarHidden:animated:] to hide the toolbar instead:
[self.navigationController setToolbarHidden:YES animated:YES];
This has always worked for me no matter how deep in the navigation stack my view controller was.
In the entire navigation stack of one UINavigationController object, every view controller's navigationController property has the same value.
The navController is like a box that contains the viewControllers within, with the last one to be pushed shown to the user until it is popped off, when the one below it will come to life again.
This means you can rely on the navController instance always being available from within a controller that was pushed by the navController.
I have a Navigation Controller with a root table view which has several links. Tapping each link moves to the next view (by pushing it to the navigation controller's stack). But suppose that in that "next view", I have a UIButton that should take me further to another view (by pushing on to the same navigation controller's stack)...
View Controller-->first view-->second view-->third view..........
Now, I can easily access the Navigation Controller when I deal with the first view (and successfully push it to the Navigation Controller's stack) because it has been instantiated in the same file itself. What my real doubt is--How do you access a Navigation Controller in a far off view controller (eg, the third view or fourth view etc)? Please note that I am not using any separate delegate. All the Navigation Bar methods have been implemented in one file and connected to the Navigation Controller via an outlet.
When you push a ViewController onto a NavigationController the ViewController will automatically have it's navigationController property set. This means you can access the same NAvigationController no matter where you are in the stack.
-Update-
navigationController
In every UIViewController you can access that property.
So to in any other UIViewController that has been pushed onto the stack you should be able to just do this:
[self.navigationController pushViewController:othercontroller animated:YES];
Look at the documentation for UIViewController to see what other magic properties you have available.
I present a UIViewController modally but would like to push another ViewController from the modal view. How can this be done as pushViewController does not work from a modal view. Thanks
Use a UINavigationController as the view that you show modal. You can then push onto that controller.
I have used a slightly different approach than Mike's suggestion. I create a navigation controller (NC) and init it with a root viewcontroller of the view controller (VC) I want to present modally. I then present the nc modally. I can then successfully push from the VC when needed.