Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jchildress

macrumors member
Original poster
Jul 9, 2008
49
0
So I'm completely new to Objective-C, about 2 days now, and I have a scripting background with a little bit of C experience. So if this question is way too newbie then I apologize.

I'm trying to create an app with a 4 button TabBar controller at the bottom, and have two of the tab views be a simple drilldown TableList controller.

Do I need to make a navigation controller to control the TableList? Or can I just add the TableList to the view of the tab and it will do the drilldown for me?

And I guess if somebody can suggest a code flow for this idea, that would be great. I'm thinking that I should first create a tabBar program project. then modify the tabBar to have 4 buttons that each point to a simple view. then build upon each of those views.

Any suggestions or comments would be appreciated.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
You will most likely want a navigation controller, because that is what allows you to go forward/backwards with different views. But yes, start off with the tab bar, then add in the view controllers (which will probably all be navigation controllers, which in turn contain table view controllers and standard view controllers). Lots of view controllers :)
 

jchildress

macrumors member
Original poster
Jul 9, 2008
49
0
This is where I get confused. let me try to explain what I have going.

My main app is an NSObject with a window and UITabBarController. I have the tabbar controller setup (in the mainWindow.xib file) in UI builder to use 4 buttons and each button links to a new NIB file. all 4 nib files are are simple UIViewControllers. This works as expected and I assume that the NIB file handles all of the view switching behind the scenes becuase I do not see any code that handles tabbar buttons being pressed.

So when I want add a drill down to the first tabbar view, I assume that I need to make a navigationController that has a window itself? And I tell the navController to fill in the window with each layer I'm drilling down in? Or does this happen automatically like the tabbar handles the view switching?

Can anybody point me to some sample code that does this exactly? Apple has a lot of sample code but nothing that does this? At leaset nothing that I can find.
 

nottooshabby

macrumors 6502
Jul 12, 2008
411
83
This is where I get confused. let me try to explain what I have going.

My main app is an NSObject with a window and UITabBarController. I have the tabbar controller setup (in the mainWindow.xib file) in UI builder to use 4 buttons and each button links to a new NIB file. all 4 nib files are are simple UIViewControllers. This works as expected and I assume that the NIB file handles all of the view switching behind the scenes becuase I do not see any code that handles tabbar buttons being pressed.

So when I want add a drill down to the first tabbar view, I assume that I need to make a navigationController that has a window itself? And I tell the navController to fill in the window with each layer I'm drilling down in? Or does this happen automatically like the tabbar handles the view switching?

Can anybody point me to some sample code that does this exactly? Apple has a lot of sample code but nothing that does this? At leaset nothing that I can find.

I'm struggling with the exact same thing. I got as far as getting my tab bars to bring up a blank table view, but could never get any cells to show up.... If you get this working let me know!
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
This works as expected and I assume that the NIB file handles all of the view switching behind the scenes becuase I do not see any code that handles tabbar buttons being pressed.

The tab bar controller handles the buttons for you. You give it view controllers, and it creates the buttons based on these and selects the view controller based on which button is being pressed.

So when I want add a drill down to the first tabbar view, I assume that I need to make a navigationController that has a window itself? And I tell the navController to fill in the window with each layer I'm drilling down in? Or does this happen automatically like the tabbar handles the view switching?

You will need to make a navigation controller. This handles the bar at the top, its buttons and sliding views from left to right. You need to create view controllers that get pushed and popped from the navigation controller. If you want a table, use a table view controller.

Can anybody point me to some sample code that does this exactly? Apple has a lot of sample code but nothing that does this? At leaset nothing that I can find.

Apple has tons of code on how to do all of this. Plus they have lots of documentation/guides/tutorials that go in specifics.
 

jchildress

macrumors member
Original poster
Jul 9, 2008
49
0
Can I make one of the tabBar views reference a NIB that has the view, navController, TableList all in the same NIB? or is that not a good idea?

The NIB file that is loaded by the TabBar, should that be a UIViewController that somehow accesses a navController? OR should I make it a navController from the beggining that then accesses the proper tableLists?
 

bones237

macrumors newbie
Sep 15, 2008
1
0
i would REALLY like to know if anyone got anywhere with this....PLEASE!!! HELP!! I have been working on this for 3 days now with no result. I have a tab bar controller with 4 tabs. 3 of the tabs are just text fields, labels and whatnot but the fourth tab i need to display a table that retrieves its editable data from a plist. I changed the 4th tab to a navigation controller via IB and i can display section headers, push/pop new view controllers but not a single cell will show up.
Please anyone???
 

CoreNet

macrumors newbie
Oct 17, 2008
1
0
Working solution...

I am trying to do a similar project and here is what I am trying to do and how I finally got it to work. I am fairly new to iPhone development so I cannot attest to how efficient this is, but I can say that it works.

I have a tab view with 4 tabs each with an external nib file and controller class. Tab #4 is a simple view for an about page describing the application, so I have it set to a regular view.

Tabs 1 - 3 are set to navigation controller views. To set this in interface builder, double-click on your "MainWindow" nib to pull it up and then SINGLE-click on the tab view controller to select it. Hit "Command-1" to pull up your attributes inspector. This is where you set the assigned controller for each tab's view. Set the ones you want to have a nav bar to have a class of "Nav Controller."

Now double click the Tab view controller icon to pull it up. Click on tab #1 - it should NO LONGER say it is loading an external NIB, that is ok. Click in the main area where it says, "View". Then hit COMMAND-4 and set the class at the top to match your view controller class.

As long as each class handles the UITableView information, you should now see each tab have a nav bar with a working table view underneath that does NOT scroll the nav bar out of view.

Hope this helps!

John
 

Yablargo

macrumors newbie
Jan 4, 2009
1
0
Thank you! this was driving me nuts! Here I thought hte "hard work" was done creating all of my back-end classes and I was going crazy getting a navigation bar above certain tab windows. woo.

I am trying to do a similar project and here is what I am trying to do and how I finally got it to work. I am fairly new to iPhone development so I cannot attest to how efficient this is, but I can say that it works.

I have a tab view with 4 tabs each with an external nib file and controller class. Tab #4 is a simple view for an about page describing the application, so I have it set to a regular view.

Tabs 1 - 3 are set to navigation controller views. To set this in interface builder, double-click on your "MainWindow" nib to pull it up and then SINGLE-click on the tab view controller to select it. Hit "Command-1" to pull up your attributes inspector. This is where you set the assigned controller for each tab's view. Set the ones you want to have a nav bar to have a class of "Nav Controller."

Now double click the Tab view controller icon to pull it up. Click on tab #1 - it should NO LONGER say it is loading an external NIB, that is ok. Click in the main area where it says, "View". Then hit COMMAND-4 and set the class at the top to match your view controller class.

As long as each class handles the UITableView information, you should now see each tab have a nav bar with a working table view underneath that does NOT scroll the nav bar out of view.

Hope this helps!

John
 

sfdoctorp

macrumors newbie
Sep 3, 2009
3
0
Both Nav Controller & Tab Controller -> but select tabs only!

Fellow Forum Users,

I am stumped and would really appreciate someone's help. Basically, I have created an App, using the Tab Bar Controller, that has 6 tabs. Here is the architecture:

1) MainWindow.xib
a) Tab Bar Save - App Delegate (referencing UI Window & Tab Bar Controller)
b) Tab Bar Controller - Each tab loads from a NIB (seperate XIB file), however all tabs have one view controller (called AllTabsController), EXCEPT for one.
c) Tab 4 - uses RootViewController, which is of type TableViewController, and thus is the only tab that contains a TableView.
2) TabBarSaveDelegate.h/m - This is of course the main app code, which currently contains the window element and the tab controller. it calls [window addSubview:tabBarControllor.view] in the appDidfinishlaunching function.
3) 5 basic XIB files - these files all have their views designed in the interface builder, each with unique fields and buttons, and obviously unique button/field handlers. All the handling logic is in AllTabsController.h/m
4) AllTabsController.h/m - defines all the UITextField and buttons, etc for 5 tabs, and extends the ABPeoplePicker, as three tabs heavily depend on using the Address Book picker on the iphone to pick a content.
5) ThirdView.xib - (sorry for the poor name), this XIB contains a Tableview element and a searchbar. this is connected to RootViewController - this connection is defined in the interface builder in the ThirdView.xib, as well as as part of the Tab Bar Controller, in the MainWindow.xib.
6) RootViewController.h/m - contains the code to load the table and carry out searching. The table is loaded from an array - no complicated SQL lite or web services work here.

7*) DetailViewController.h/m & DetailView.xib - this is basically to support drill down from a selection of a cell in the table view. This however does NOT work for me at this point, because of controller issues, as the design I've downloaded pushes to the Navigation controller stack (as I've seen in all the apps I have with drill down capability).


ISSUE:
For my code to work, I need to be able to use the NavigationController, in parallel with the Tab Bar Controller. I have suffered issues with control of the window, having both. What I really need is for the Nav Controller to only appear on the tab with the Table View. This should be possible, as part of the Tab Controller - since I have 6 tabs, there is a More button - it automatically takes me the exact drill down type thing I am looking for.

The question is - where do I add the Navigation Controller object? Specifically, where should it be instantiated, then do I call [window addSubView] somewhere else? I have tried adding it to MainWindow.xib and instantiating it the in root delegate, but I don't have access to [window] in my RootViewController. Since rootViewController is a controller, I dont think there is anyway to add the NavController there.

Has anyone ran into this?
 

sfdoctorp

macrumors newbie
Sep 3, 2009
3
0
this link is helpful in giving me ideas.

however for whatever reason, the solution doesn't exactly work per the instructions. I am trying it, but all I see is just the empty bar - my tableview doesn't load below it.
 

sfdoctorp

macrumors newbie
Sep 3, 2009
3
0
the answer is now on this other forum:

http://www.iphonedevsdk.com/forum/i...bs-only-tabcontroller-primary.html#post122668

>>>

You add view controllers to navigation controllers, not the other way around.

For the tab that needs navigation, in your XIB file that contains the tab bar controller, delete that tab (view controller). Grab a navigation controller from the palette and drag it to the same spot. Crack open the navigation controller, find the view controller inside it, and set that to be your custom view controller class.

>>>>>

Perfect! I got it working!

It took a while, because of the stupid saving tab order option I had enabled. I had to comment that code out.

For anyone else who needs help with this.

1) Add a new Tab, by dragging the UINavigationController from the palette.
2) Drill down into it, on the view controller, set the NIB to be the XIB you were using before.
3) Change the view controller to be the view controller you were using before.
4) Discard or move your old tab to the end (rename OLD).

The above should work straight up.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.