views:

101

answers:

1

Hello everyone,

I am very new to the iPhone SDK. I need to know if in a tab bar application I need to make UIViewController classes. For example, when I make a new tab bar application there is a default FirstViewController class (.h, .m) already there. Now if I have code on the second tab, would I need to create a SecondViewController class? If not, how would I make a button on the 2nd tab, and make that button do something. I'm not really sure how to do it, because the FirstViewController works with the buttons and code, but if I make a SecondViewController, and I link everything my app crashes.

If anyone could help it would be greatly appreciated.

Kevin

A: 

Yes, each tab needs it's own view controller and it's own view nib. If you look in the inspector in IB for the tab itself you will see that you can set the number of tabs and if you select each tab you can tell it which class handles that tab. Make sure that you set the File's Owner for each nib file to the correct view controller class. You don't need to make any connections between the various tab's controllers. If you're in doubt about something check all the connections for the FirstViewController files(.h, .m, and .xib). If you still have issues post as many details as you can as something must be screwy somewhere.

theMikeSwan
How can I make the File's Owner for each nib file to the correct view controller class?
Kevin
IB, inspector for File's Owner, tab on the right 'Identity' change the class to the correct name (it should auto complete for you as long as the header file has been saved.
theMikeSwan
Am I doing this correctly. Here is my source.. http://www.heliotop.org/test.zip
Kevin
You're almost there, both issues are in MainWindow.xib. First, check the target action of your button in the first tab (looks like you changed method names at some point). This error is being picked up by IB as seen by the yellow triangle bottom right of the doc window. Next click the "Second" tab and look at the inspector under Class in the last tab, it needs to know what controller is in charge of the tab. I made these two corrections and both methods worked as advertised.
theMikeSwan
OMG, THANK YOU SOO MUCH!! I CAN'T BELIEVE I DIDN'T NOTICE THIS!
Kevin