0
votes

I have a tabbar application. Second tab had a drill down table list with Navigation Controller. I also want to implement a segmented control inside a tool bar that shows different table entries as per the selected switch in segmented control. I am a little confused as to how to implement this?

Screen-shot - alt text

This is the view in second tab controller an instance of the generic UIViewController. Blue Background is a UIView that contains a segmented control (1,2,3,4). The steel blue navigation bar at the top is a simulated UI Element from Interface Builder. I need to put a navigation Controller such that it has a list table view that changed depending on the switch selected in segmented control UI.

I have following options

  1. Add UINavController as root controller for second tab directly with table view inside it. In that case how do I accomodate the UIToolbar having segmented control?

  2. I add UISegmentedControl as part of the view of Second Tab's view controller and add navigation based table view as another element to that view. Is this doable? How can I add a nav based controller to a UIView and control the frame so that it does not cover the UIToolBar.

I hope I am making sense. Please lemme know if you have any suggestions. Thanks.

3

3 Answers

2
votes

This is how I achieved it. In IB, in MainWindow.xib where I have a tabbarController, I made the class identity of the second tab to a UINavigationConrtroller. Then I made the main view Controller for second tab that had the segmented control and the Table View as a rootViewController to the NavigationController. This functioning exactly as I wanted. Thanks all for your help.

0
votes

you can add UINavigationController in place of UIViewController in UITabbarcontroller and Put your UIViewController who haveing UISegmentControl in UInavigationController who add in UITabbarcontroller

in reading its looks confusing but try to implement its work

Step 1: xcode-->new Project-->tabbar application

Step 2: open xib of main window select tabbarcontroller and open inspector. in that you able to see list of view controllers change their class to uinavigationController. if you need uinavigationController in second tab then change only secong tab class to uinavigationController

step 3: create new uiviewcontroller. open its xib and add uitableview and segment control to that.

Setp 4: now expand tabbarcontroller and check your second tab have navigationcontroller now add your uiviewcontroller in navigationcontroller's viewcontroller

0
votes

According to your requirements you can't avoid working with code - I mean that you can't set everything by connections in IB.

I would create a UIViewController (let's call it container) that will contain the segmented control and the navigation controller.

  • You should set the second tab to be a view controller and point it to the container.
  • Container's view (XIB if you want) should contain the segmented controller that will be aligned to bottom and a containerView that will fill the rest of the view and will have its IBOutlet.
  • Container should also have a navigation controller member that will be initiated in viewDidLoad.
  • The table view that you talk about should also be built in its own XIB and have its own view controller that will be set as root view controller to the navigation controller...

Tell me if it's too confusing / complicated...