Oh and by the way, it makes it easier to understand whats going on if you switch the view mode of your interface builder xib to the tree view. Thats the 2nd icon in the group of the icons in the MainWindow.xib window in IB. Like once you have a view set to a navigation controller you can expand the tab bar controller and see the navigation bar it has added which your controller then automatically uses.
Ok, so I have 2 tab bar items that will be simple views with no navigation. So, I created 2 xib files for them. Im trying to load them, but my app terminates when I click on the tab button and says no view was loaded. Here is the code.....
Well I was gonna ask him why he is trying to use code but then I thought if I wrote something that might confuse him, perhaps he will read my earlier post and give IB another go.
Ok, so I have 2 tab bar items that will be simple views with no navigation. So, I created 2 xib files for them. Im trying to load them, but my app terminates when I click on the tab button and says no view was loaded. Here is the code.....
Any ideas how to load these 2 views from XIB files? If I just alloc/init them, the app works, but of course, the view isnt loaded.
Your issue is quite simple. You placed the viewController XIB's and told the interface file that it was in the MainWindow.xib file, which it clearly is not.
Remove the IBOutlet off of the interface bits
Last edited by DevTeamOfOne; 08-23-2008 at 03:33 PM.
Well I was gonna ask him why he is trying to use code but then I thought if I wrote something that might confuse him, perhaps he will read my earlier post and give IB another go.
That might have something to do with the fact that he is using separate XIB files
Your issue is quite simple. You haven't added the controllers correctly. Why are you doing your initialization of the tabBarItems in the App delegate? Do it in your tableViews.
Next... You haven't added any navigation Controllers. If you didn't want to have them, then just add the controller as you have without the tabbar item info.
If you add the navigation controller, follow the guide i placed on page 1.
Thanks! Ill give this a shot.
I do have a nav controller for tab 1. I just didnt post it. Its working fine.
DevTeamOfOne, I think RockStrongo justifies my point. Something that takes 2 seconds in IB he is stuck on in code.
Well, I really want to understand the code too. Using Dev's suggestions in this thread, I created a skeleton for my app and its working.
After getting this down, I wanted to use XIB files for these 2 simple views.
They are more visual in nature, so I wanted to see them in interface builder and play around with them there. I would not have used IB for the whole project.
In the long run, I think learning this programmatically will be more beneficial. Just my opinion.
If RockStrongo doesn't understand the concepts here, then there will be major reprecussions for the rest of his app building. The concepts of Cocoa Touch and objective-C are understood perfectly by a good understanding of what is going on between a Tab Bar, a Navigation Bar and a Table View.
By cheating with IB, RockStrongo will lose the opportunity to learn how to do these simple Objective-C procedures.
Your code to create a tab controller with navigation controllers within it works great! I have one question. I have a tab bar controller where one of my tabs (not the initial view) is a UIWebView.
How can I have the webView load a URL without having to activate its tab and click a button. Do you know how I can load the request from the appDelegate?
@indiekiduk
Do you now of a video that shows how to do this via IB? Like everyone else on this thread I am very new to IB and to me there is a steep learning curve. When you say "Click the status bar of the tab bar controller icon in IB" I don't know what you mean along with everything else you say in your comment #50.
What I am trying to do is start with a Nav template and then add a Tab Bar. Both view needs will have a TableView in them.
Ok I have made you a quicktime video, sorry no audio.
Tab Bar Demo
In this app I have a Tab Application with 2 tabs. Both tab views are set to Navigation Controllers - that is why you see a navigation bar in both tabs. The first view in each navigation controller is set to load from seperate XIBs. Both FirstView.xib and SecondView.xib are UITableViewControllers. I created 2 UITableViewController subclasses which each xib's File Owner class are set to (That is the blue square).
Extra notes:
1. I had to delete the SecondViewController.m and .h files because they were subclasses of UIViewController and not UITableViewController. I could have changed the code but if you use the class wizard you get all of the table methods in the file when it is created.
2. I had to add the CoreGraphics framework because it would have failed to link the CGRectZero symbol which is needed to build. Apple should have included this by default.
3. Oops I didn't really need to delete the original SecondView.xib I could have just edited it.
Hey Dev...ok, so what did you mean by saying the interface file thinks its in the MainWindow.xib?
When I remove the IBOutlet's, it still performs the same.
How is MainView.xib associated with the app delegate? If I understand that, it might help out.
MainWindow.xib is tied at the base level with your app delegate through the info.plist file.
When you call IBOutlet in any interface file, you are saying: When my app launches, this section is shown in the IB file it launched with. In this case, MainWindow.xib.
What you need to do: call it as a property, that is, take out the IBOutlet bit, and also add in the @property bit.
Then Synthesize it into your app in the implementation file.
Then say
whateverItIs = [[WhateverItIs alloc] initWithNibFile:whateverItIs bundle:nil]; in the appDidFinishLaunching bit.
that creates a property that holds through the entire app. That property you have said, is a class of WhateverItIs, and you are telling the compiler to initiate it by activating the XIB file in no bundle.
Your code to create a tab controller with navigation controllers within it works great! I have one question. I have a tab bar controller where one of my tabs (not the initial view) is a UIWebView.
How can I have the webView load a URL without having to activate its tab and click a button. Do you know how I can load the request from the appDelegate?
You're the man.
Well, This may seem like a simplistic way... send it a message
I have a three tab views, in the first tab i need to show web view then in the second tab i need to show table view and third tab i need to show couple of text and label with one button(like user login screen). I can able to develop UI. first tab view i added UIWebView then second tab i added UITableView then third tab i added simply UIView. How do i create corresponding .h and .m file to display google page on first tab, list of names on table view and login ??????
If you'd like to send your project to my email address send it to sonofstrength@hotmail.com, and I should be able to help you better. I am finding it a little difficult to see what you mean, but the code should make this clearer
dev your code helped me a lot. one question, however: how do i add icons for the view controllers that i added to the tabBarController? I've been stuck on that for a while.