views:

56

answers:

1

I'm attempting to add view controllers to my tabbarcontroller, and then make the first one the selected one using the following code:

[self setViewControllers:[NSArray arrayWithObjects:self.detailController,self.mapController,nil] animated:NO];
[self setSelectedIndex:0];

When this code is called, the correct view controllers/tabs are added, but none are selected. Is there a better way to do this?

Update: To add more context, the above code snippet is being called in the viewDidLoad method of a viewcontroller that subclasses UITabBarController.

A: 

http://stackoverflow.com/questions/833389/uitabbarcontroller-is-possible-to-select-the-tab-via-code

looks like it answers you question based on the code you have provided; if not can you show the code in context?

Aaron Saunders
That other question says the same thing im currently doing. The trick is the controller isn't responding.
midas06