Can a UINavigationController contain a UITabbarController? - iphone

I want to have a UIView inside of a NavigationController that has 4 buttons. Clicking on any of these 4 buttons will push a UITabBarController that contains a NavigationController with a respective UIView.
Is this possible? Tweetie seems to do something similar.

On my application, I have a tab bar view controller, then inside of that, I have navigation controllers going to individual views in my interface builder. I believe if you just copy this format, it will work.(-> means connected)
Tab Bar View Controller->4 separate Navigation Controller->ui views
I hope this helps

Related

Show UITabBar on UIViewControllers that are not part of the UITabBar?

I have an iOS app written in Swift with UITabBarController with 5 UIViewControllers. Now, I have a bunch of UIViewControllers that are not part of the UITabBarController. I'd like to be able to show that same tabbar but I have no idea how to do that. Any clue?
More details: This is one of the View Controllers that the tabbar has. I use storyboard references and split my view controllers into separate more manageable storyboards.
So, the big picture:
There's no initial ViewController since I use storyboardId to get to the initial Navigation Controller. From there we have a ViewController embedded in the same Navigation controller. In that ViewController, there are 2 Container views - one of the size of the bottom ViewController that contains the "hamburger" button that toggles the other Container View which has an embedded UITableView in. When a specific cell is selected it should go to Profile ViewController that's not even in the same storyboard. The segue is set to be Push. Either way, doesn't show the UITabBar on the Profile ViewController
how you doing?
I don't know if I understood, but you are trying to show tabbar after going to another screen, right? If the answer is 'yes', try to change your segue to show(e.g. push).
-----Edit-----
You can do with two ways:
Presenting Modally -> using Current Context
Use push(e.g.) with a navigation view controller, you can also hide the navigation bar if you go to Navigation controller -> Attributes inspector -> Navigation Controller -> Uncheck Shows Navigation Bar
Hope now it works!
Best regards

View Hierarchy with UIToolBar and UITabBarController

I have a rootViewController that is a UITabBarController. A UIToolBar is present in that controller since it has a SearchBar that is global to the app. In certain tabs, there should be specific UIBarButtonItems, or UISegmentedControl, along with the searchBar. In other tabs, there should be nothing in the toolBar, just a title.
What is a good way to lay out the view? Currently based on what tab is selected, the main toolBar from the rootViewController is either used as it is, have a UISegmentedControl added to it, hidden completely and replaced with another viewController that has its own toolbar, etc. To me, I'm thinking that each viewController that is present in its own tab can have its own ToolBar, and reference the global functionality, vs hiding/showing different toolbars.
sorry if this is a convoluted question. Just wondering if people had experience with this. Thanks.
The short answer is that there isn't really a good way to do this. If you're using a tab bar controller, the tab bar will always be visible along the bottom of your screen. Presumably each tab is a UINavigationController with a navigation bar at the top. There's not an appropriate place to put toolbar buttons in this layout.
A better design could be to abandon the UITabBarController and use a UINavigationController as your root view controller. Instead of tabs, you can have a table view with an item for each view of your application. Then you'll have room for a toolbar at the bottom of the screen. In fact, UINavigationController supports having a toolbar at the bottom. You just override the toolbarItems property to return the items that should appear in each of the child view controllers. You'll just need to set toolbarHidden to NO on the UINavigationController, and you're good to go.

UITabBarControllers and UINavigationControllers

Problem
I have an app with a UITabBarController and four different tabs. Three of these tabs are tables which you can click on each row and it would take you to another view.
Question
How would I implement that in terms of navigation? Should I create a UITabBarController with Navigation Controllers as tabs (as shown in image 1) or with View Controllers as tabs (as shown in image 2) with each View Controller having its own Navigation Controller property?
Image 1:
Image 2:
I tried both but its not working well and its confusing. I'd like to know which is more appropriate so I can focus on that method and then see why it's not working.
The first method you propose is the only method. View controllers have a navigationController property, but it will only return something if your view controller is currently contained within a parent navigation controller.
So to be clear: you should have a UITabBarController which contains your navigation controllers, one navigation controller for each tab that you want to have a navigation hierarchy in.

Adding Tab Bar Controller to Root View of UISplitViewController?

How would I set a UITabBarController with all its individual view controllers as the root view in a split view? IB doesn't seem to let me change the class of the root view controller to anything else…I'm using Xcode 4.
Are you using the split-view based application-option? In that case, it worked for me to just extend : UITabBarController in the RootViewController.h-file. I'm not sure what behaviour you want here, but if you set it up like that, you should get the tabbar with all your views (you have to add them in RootViewController.m ofc) in the "root"-option on the navigation bar.
If you want the DetailView to show the same, you have to add a navigationcontroller to the detailview as well.
As for the "more elegant" solution with IB, I'm afraid I'm not very fond of or very experienced with IB.
You want to add tabbarcontroller to your split view at rootview side and its very simple.
create as many viewcontrollers subclasses with xib for ipad as u want to put in tabbarcontroller.
Then expand your splitview , u have two things navigationcontroller(which in turns contain rootview controller),detailview controller(right side view).
Open your library just drag tabbar controller exectly onto navigationcontroller ,so it will replace all that navigation controller and rootviewcontroller(i assume u dont need that rootview controller or u can create it later).
now expand this tabbar controller u can see viewcontroller 1 - viewcontroller 2 etc.
Now simply select view controller 1 , open attributes and select nib file on [command 1 attribute] and select controller file for that nib file by press[command 4 attribute].
Reapet this for view controller 2 in tabbarcontroller and save close IB.
run program select landscape then u can see its done.
Thanks to dh14-sl and lecou—the solution was a combination of both your answers. I was trying to drag a tab bar controller from the library onto the list of elements but it wasn't working—turns out I had to drag it to the view itself. Then I had to change the parent class of my rootvc and re-setup connections, but now it seems to work! Thanks guys!

UINavigationBar with TableView and Segmented Control inside UITabBar

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