Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SqueegyX

macrumors regular
Original poster
Mar 24, 2008
108
1
I have a view with a controller that descends from UITabBarController. In the nib that is loaded by a tab, I set the File's Owner to a custom UIViewController I have and wired some buttons to it.

When I run it, it works and I see the view. But when I push the button, it crashes with an "unrecognized selector sent to instance". So its not send the linked message where I think it is.

And I appear to be able to set controller type for each tab in IB, but the list doesn't allow me to choose a custom controller class.

So I guess my question is, how do I wire up and respond to actions that happen in a nib loaded by a UITabController? Especially since I cant drag connections between nibs :(
 

SqueegyX

macrumors regular
Original poster
Mar 24, 2008
108
1
After reading a bit in the view controller programming guide, I have decided to create the tab bar controller completely via code. However, their example isnt working at all

Code:
  GalaxyMapController *mapController = [[[GalaxyMapController alloc] init] autorelease];
  LoadoutController *loadoutController = [[[LoadoutController alloc] init] autorelease];
  hyperspaceController.viewControllers = [NSArray arrayWithObjects:mapController, loadoutController, nil];
  NSLog(@"view controllers count: %i", [hyperspaceController.viewControllers count]);

This prints out "view controllers count: 0". Any clue why they are not being added?
 

SqueegyX

macrumors regular
Original poster
Mar 24, 2008
108
1
Ok, finally figured this out. Turns out the DOCS ARE WRONG.

This page https://developer.apple.com/iphone/...ngToolbarControllers/chapter_6_section_3.html says to do this:

Code:
tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];

But the designated initializer is actually supposed to be:

Code:
tabBarController = [[UITabBarController alloc] init];

That change now allows view controllers to be added and displayed.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.