user711643
user711643

Reputation: 297

How do I change TabBarController behavior?

I'm an iPhone newbie and for my first application I need to override the normal behavior of TabBarController. I have 3 tabs and on the first one I need to load a different view according to some logic at runtime. Is this possible?

I had a look at the TabBarController delegate but as far as I understand it doesn't allow behavior override, just "notification on user input".

Any idea? Thank you.

Upvotes: 0

Views: 155

Answers (1)

Adam
Adam

Reputation: 33126

To change the controller in a particular tab, you do:

NSMutableArray* controllers = [NSMutableArray arrayWithArray:tabBarController.viewControllers];

int newIndex = 0;
[controllers replaceObjectAtIndex:newIndex withObject:newController];

tabBarController.viewControllers = controllers;

Upvotes: 1

Related Questions