Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Very basic problem with Tab Bar Application and Interface Builder

OK, here is how to re-create the problem I have:

1) Create a new project, using the Tab Bar Application
2) Add a UILabel within SecondView.xib
3) Add IBOutlet UILabel* myLabel; to FirstViewController.h
4) Connect up myLabel in IB.
5) Build and run.

When I click the second tab the app crashes with:

_TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION_

I can't figure it out!

Any help much appreciated.

Cheers,
Rew

MacBook 2.1 GHz IntelCore2Duo 4GB DDR2 SDRAM, Mac OS X (10.5.4)

Posted on Jul 12, 2008 5:32 AM

Reply
27 replies

Jul 12, 2008 9:48 AM in response to DavidHouse

Thanks David, I've checked the File Owner 'View' and all is connected up fine.

I think it's something to do with the UITabBarController in Interface Builder. For the UITabBarController there are two UIViewControllers (so you tab between two views). One UIViewController is set up so that in 'View Controller Attributes' the 'NIB Name' is set to the name of the NIB file (without any file-extension).

I've tested this part and it works fine, but it only stops working as soon as I add objects to the UIViewController and try to connect them up. Left un-connected, it works.

Jul 12, 2008 10:16 AM in response to rew.islam

No solution yet, but it happens to me if I follow your same exact steps. I haven't really done anything with the UITabController yet, so I'm not sure how to solve this. One thing you can try is to create a new class to function as a delegate for that view, add an instance of it in Interface Builder, then connect the label to it instead of the Files Owner. It just might be the order that things are happening it is trying to reference the label before it has been created.

Jul 12, 2008 10:28 AM in response to DavidHouse

Hmm, that sounds plausible. I'm not sure I completely understand what you suggest... but I've mailed Tech Support and asked them to look at this thread.

If they reply and I solve the issue, I'll post here.

I'm sure the solution is very simply, which is very frustrating. I only recently decided to go all out with using IB, rather than set everything up in code, I'd still like to go down this route, hopefully someone can point me in the right direction soon.

Jul 13, 2008 1:06 AM in response to rew.islam

OK - I have found the problem.

In IB, when using UITabBarController which has multiple UIViewControllers which all separately have their own NIB file assigned, there are two places where you need to set your UIViewController class file.

First, the obvious one was within the NIB file for each UIViewController.

Secondly, where I'd missed it, is withing the NIB file for your UITabBarController. In each UIViewController, not only do you set your NIB file, but also the Class.

Many hours later - I am a happy person.

Very basic problem with Tab Bar Application and Interface Builder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.