Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to : Navigation Controller in Tab Bar Controller

I'm woking on a simple iphone application. The applicaton has a table view on first screen. If the user clicks on an item on that table view, application navigates to the second view. The second view has a table view, too. If the user clicks on an item on this screen, I want to show a new xib which has Tab Bar Controller.

Actually, I did it. But, the problem is that I can't see the tabs. The tabs are shown at the bottom, outside of the screen. How can I solve this problem?

Thanks.

like image 711
Murat Avatar asked Jan 29 '09 08:01

Murat


People also ask

How do I get navigation controller root view controller?

The root view controller is simply the view controller that sits at the bottom of the navigation stack. You can access the navigation controller's array of view controllers through its viewControllers property. To access the root view controller, we ask for the first item of the array of view controllers.

How do I add a navigation controller to my storyboard?

Under the View menu, select Utilities→Show Object Library. In the Object Library, find the Navigation Controller object (see Figure 4-7) and drag and drop it into the storyboard, to the left side of your existing view controller (Figure 4-6).

How do I segue to my navigation controller?

To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.


2 Answers

Here is an tutorial that I was able to get working.

I also read the official SDK documentation on the topic: Combining Tab Bar and Navigation Controllers. Since I'm still learning, the tutorial helped me more than the docs.

NOTE: in the tutorial, i don't think you need to subclass UINavigationController, and I'm experimenting with this idea now.

UPDATE: I was able to get the tutorial working without subclassing UINavigationController. So a subclass is not required.

like image 102
bentford Avatar answered Oct 20 '22 00:10

bentford


Open Interface Builder.

Click a tab and check whether sub-controller(of tabbar controller) is UIViewController or UINavigationController. (Default: UIViewController)

If UIViewController, replace it with UINavagationController.

And Set the root view controller of UINavigationController to first view controller.

Last, call pushViewController method, not presentModalViewController method.

like image 24
ChangUZ Avatar answered Oct 19 '22 22:10

ChangUZ