views:

58

answers:

1

I have a tabBarController xib. I've set the first item's class to a view controller I made (.h and .m files, no .xib). When I try to push the tabBarController, I get a warning saying the tabBarController "view outlet was not set".

I'm not sure how to set the view outlet, since I am loading from another view. I'm expecting the default grey view with detailed edges will load from my ViewController.h file because I set the class there, but instead I'm crashing with that error.

Suggestions?

A: 

Normally, you would add view controllers to the tab bar controller in the xib. They need to have a view linked up, which you can also do in IB.

If you want to do that programmatically, you should, after loading the xib, but before showing the vc, take the elements of

NSArray *vcs = [tbCtrl viewControllers];

walk through them, and set their view property to a view. When pushed, the tab bar controller will know which view to load: namely the view of the first tab. These things are really much easier to handle in IB.

mvds
@quantumpotato In short you should modify your tabbarViewController's viewControllers array.
Madhup
@Madhup: I don't think this is correct, the viewcontrollers seem to be there (reading the question) but the views are not. Modifying the viewControllers array will not help.
mvds
@mvds I just summarized your answer, the warning is due to the factor, that the view in XIB is not linked with the viewControllers's view
Madhup