Tabbar not showing after a segue? - swift

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.

Related

Why doesn't the first navigationcontroller in my storyboard have an effect on the tableviewcontroller?

My Storyboard is setup as:
UIViewCont
/
NavigationController -> UIViewContr -> UIViewContr ----- UIView Contr
\
NavCont
\
TableViewController
The last three controllers (2 x UIView and 1 x TableView) use "show" segues from three different buttons. And the TableView controller is embedded in the NavCont.
Because the first controller is a NavController every UIViewController has a back button except the TableViewController.
I've been reading up about it but can't figure out why. Other than each Navigation controller is it's own stack and kind of starts again so you can't just navigate back from a 2nd or 3rd navigation controller. But not sure.
Thanks.
Using a navigation controller resets the navigation stack tracking, so your table view does not have a back button because it is effectively a new root. If you create a view controller that the table view segues to, it will have a back button because it is part of the (inner) navigation chain and not the root.
It is not apparent from your example what you are trying to do or why you have the inner navigation controller instead of just relying on the original navigation stack. There is one option you can try. The root view of a navigation stack should have the navigation bar, and you can drag bar button items onto it, allowing you to unwind back to the previous state.

Is Initial View Controller does work?

I have a viewcontroller and a tab bar controller. I want to change view controller as initial view controller and create a segue to show tab bar controller.
I have tried to set the new initial view controller. There are 2 ways. First, check the tick box "Is Initial View Controller". Second, drag the arrow to new screen. It does not show any error, but it shows the tab bar controller as usual and I can't find the view controller either.
Anyone know how to what is going on. Please tell me to fix. Thanks
You need to use a UINavigationViewController and connect it up in the hierarchy in a similar fashion to:
The leftmost view is the "view" that you mention, which needs to show the UITabViewController.
I've added a button for ease of use.
The next along (send from the left) is the UINavigationViewController. No settings on here need to be set etc... it's pretty much "plug and play" as to put it.
The next view (third from the left) is the UITabViewController (with corresponding views to it's immediate right).
The connection between the UINavigationViewController and the UITabViewController is "rootViewController" as the Tab View is the "root view controller" e.g. the primary view controller.
The segue between the first view, and the navigation view controller is merely a "show" segue. I liked directly between the button and the navigation controller in Xcode.
Hope this mash-up helps!
Edit I wrote a quick mask up of what I posted in the images for you to play with: https://dl.dropboxusercontent.com/u/61211034/Stackoverflow/NavgationViewController.zip
Based on your storyboard's image, looks like you don't have any NavigationController embedded to your root LoginViewController, try this:
Select your LoginViewController on your storyboard
Then in xcode Menu bar at the top, go to Editor -> Embed in -> Navigation Controller (as you can see in the image below)
Then your NavigationController will be set as your Initial View Controller, and see your LoginViewController be displayed and work as expected your segue.

Push UITabViewController from UIViewController is possible?

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 ..

Iphone UIViewController to UINavigation controller programmatically

I have been stuck on this for a few days now and it is killing me... In my viewDidLoad event, I am trying to programmatically add a full screen UINavigationController to a subview of my view controller. So far, I have only succeeded in doing two things...
1) Only a grey screen shows up
OR
2) I get something that resembles a navigation controller added to the view controller, instead of being my navigation controller from a XIB it is just a generic one... even though I loaded from the XIB. Oddly enough it is always shifted 25 pixels downward and slightly cut off.
I have read every single link on google and I can't seem to figure this out. I just created a new viewcontroller... added a UINavigationController to it... try to load that view controller and it messes up.
Any help is greatly appreciated!!!!
Instead of having the UINavigationController be a child of some other view controller, make the UINavigationController the root controller itself. The navigation controller is one of the special "container" view controllers, and it generally wants to own the whole screen and be at the root of the controller hierarchy (except in certain circumstances).
Try something like this:
UINavigationController * rootNavController = [[UINavigationController alloc] initWithRootViewController:myRootControllerInTheNavController];
[window addSubview:[rootNavController view]];
Which will obscure any existing views with the nav controller (those existing things will still be there when you -removeFromSuperview the nav controller's view). The nuclear option is to set your UIWindow's rootViewController property with the nav controller, but it sounds from your comment that this may not be what you want to do here.
Possibly a cleaner approach: If it accomplishes what you want, I believe you could also take your nav controller and present it modally (see docs for uiviewcontroller) from whatever the current view controller is. Set the transition appropriately, and while you're in the nav stack, the nav controller will be visible.

Switching Views within UITabBar View

I have created an UITabView application. Each view selected from the bar is a seperate controller with own nib file. I switch between them succesfully.
In the first view I have two buttons (check out the screenshot). When clicking them I want to switch to another views which are the parts of the current view controller. I use:
[self presentModalViewController:anotherViewController animated:NO];
That switches the view, but hides the UITabBar. How to keep the bar on the screen after the switch?
P.S. Sorry for the blurred image. I am not allowed to share to much info.
Well I think you are misusing the modal view controller. For a problem like this I'll say you should put them in a view controller stack using UINavigationController. Instead of making each tab a UIViewController make it a UINavigationController, then you can push and pop view controllers on it, which still show the tab bar.
See http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html
use: tabBarController.selectedViewController = newViewController
edit: UINavigationController is not needed here.