tab bar in a view based application - iphone

I am building a view based application in xcode, and i am new to all the coding and stuff doing it now for 2 weeks. everything went great until i wanted to add a tab bar to by project.
I have searched the interwebz for this for a long time, but all that i could find was people explaining how you can add a tabbar to a window based application, Or how to build a tab bar with a tab bar application. Can someone please help me.
And there is one more thing, i don't want to add the tabbar to the first view. I have an application with some buttons, who take you to different views, and i want to add the tabbar to the fift view, so i can not build it in the app delegate i think.
I hope this explains my problem and i sure hope someone could help me.
thanks.

Start with a UITabBarController.
WHen you use it in Interface builder you can add UITabBarItems (the items to select).
You can link each TabBarItem to a certain NIB. Make your NIBs for every view you want to show. Set every TabBarItem class to the correct controller of your NIB files, these will be used as the file owner of that NIB.
So:
-Make a Main NIB
-Make NIBs for every controller and make the views.
-Make the controllers and link the controllers to the NIB.
-Implement the code.
Switching UITabBarItems will make automatically change the Controllers.
Here is a tutorial for this implementation: Tutorial

Related

XCode 4.1 - Multiple view within a XIB

I have created an application successfully and given it a TabBar view controller that is working as i had hoped, but have run into a glitch.
On each xib i load from the tabBar I need to create sub-views that will perform tasks as this interacts with a database (or .. will). I have created my first page and the buttons that will navigate to the views within the XIB, but do not yet nkow how to navigate between views within the XIB itself.
would it be better to have seperate XIB's that load when the buttons are hit?
OR
should i create views within the XIB's for each category and switch between them?
I am still learning and have had some confusion regarding navigation as I already have the TabBar controlling the root of the application. I have been looking for tutorials, but they all seem to start at either navigation controller as the root, TabBar as the root, and nothing like I need for option 1 above.
I can add details of the app if needed, but am looking for guidance for now.
Thank you,
Silver Tiger
To navigate between views the best way is to use a navigation controller pushing/popping separate view controllers, loaded from separate nibs. UINavigationController is a subclass of UIViewController, so you can perfectly put a navigation controller for each tab. You can also use story-boarding in the new xcode 4.2, but I recommend getting comfortable with this before doing so.

Tabbar with different Data

I am trying to develope an iPhone App for 3 months.
I found everything myself in books or the internet. Now I have a problem that I am not able to solve myself.
I would like to develope a tabbar application with 3 tabs.
In each tab is a navigation controller with a tableview.
The tableview loads the data from an XML file on the web. The difference between each tab is only the difference XML-url. The tableview and function should everywhere the same.
What have I done?
Created a tabbar application
Put 3 Navigation Controller in the Tab Bar Controller in the MainWindow.xib
Every View in each Navigation Controller points to the same "TableView" class
Now it loads on every tab the same tableview. But I just want to change the XML-URL which is loaded. But I dont know how to implementate this.
I hope that somebody can give me a hint? Thank you!
Are you sure you need a Tab Bar? You could just add an additional level of navigation on top for the sources. So your navigation controller stack would be like
UINavigationController -> SourceViewController -> ListViewController -> rest of your navigation stack.
ListViewController is a subclass of a UITableViewController which is passed the source url based on selection from SourceViewController which can be a subclass of UITableViewController too. This will save you of the repetition you are trying to avoid and is more likely a better option for the thing you need.
Now if you insist on using a Tab Bar, your stack will be more like –
UITabBarController which will have three instances of UINavigationController each with its own instance of ListViewController which like before will be initialized using a source url.
Now it may be smarter to reduce it to a single ListViewController and attaching all the navigation controllers to it. You can do this using the -tabBarController:didSelectViewController: method in the tab bar delegate. On every tab change/call, you clear the current cache that is providing data to the table view and load the appropriate cache based on the source XML of that tab.
Usually state is preserved on tab changes but using this structure you will have to do additional work to get that.

iPhone Dev: Tab View controller. Buttons on first view don't show actions in File's Owner

Hey all, I'm really new to iphone development and am getting really frustrated. I know ASP and Javascript and i'm trying to do this objective-c. I took a course on lynda and now i'm trying to hook up a tab view.
I placed buttons on the first view of the tab view controller. I then went into the header file and created the - (IBAction) for the 4 buttons on there and added the function in the implementation file. The problem is when i go back to Interface builder and try to connect the actions to the buttons, they don't show up. I have no actions listed in the File's owner so i can't do anything. Can anyone out there please help! thanks.
damien
You're doing it backwards (IMHO). create the Actions and Outlets (don't forget to save the source), then create the items in IB (note that you have to refresh IB so that it can re-read the source.
In tab view controller app make sure that class of view is your ViewController class and also in MainWindow.xib make sure all tabs are referencing respective ViewController

iPhone app like Twitter design structure

I'm new to iOS development and am working on this app that has a similar interface to the official Twitter app. However, I'm not sure how to organize the view controllers and the hierarchy, especially for UITabBar and UINavigationBar (which one is the parent controller?).
Can you guys point me to the right direction? I started from a blank window-based application project. A list of view controllers in the order of the hierarchy would be really helpful. Thank you.
Make the TabBar Controller your root controller. Then, in every tab where you need navigation, use Navigation Controller. It will add Navigation Bars, which you can then modify either in IB (where it applies), or programmatically.

Moving a 'UITabBarController with UINavigationController' iPhone app to 'UITabBarController with UISplitView' on iPad

I have an app where the appDelegate has a UITabBarController. Each of the tabs has a navigation controller which I currently use to push a single detail view onto the stack in each tab. I am hoping to replace my navigation controller on each of the tabs with a splitViewController. I use the Interface builder to provide the UINavigationController for each tab. I am having trouble loading a nib for each tab that has a UISplitViewController in it. I am getting an instance of the UITableViewController class displaying on the screen, but I am not getting the UISplitviewController or the Popover or the detail view etc. These classes are all working in a standalone app, but I am not able to get them into each of the tabs in one app. Although I am currently using the Interface Builder I am open to doing this programmatically. If someone has suggestions, or an example small project of a Tab based app with individual split views in the tabs I would appreciate it very much. (As this is my first question I am not sure how much code or other pictures from IB would be helpful for me to post. If you need further detail please let me know and I would gladly amend this post.)
Apple documentation
"The split view controller’s view should always be installed as the root view of your application window. You should never present a split view inside of a navigation or tab bar interface."
Moving on...
Not only shouldn't you -- if you do so, an error is thrown when you run. It's impossible.