user1927638
user1927638

Reputation: 1173

Setting the initial view controller for tab bar

I am attempting to create an iOS project with a tab bar controller. Essentially, what I am trying to do is make a specific tab selection to default to the initial view controller or the top view controller of the navigation controller.

Tab Bar Controller ---> Tab 1 ---> Navigation Controller ---> ViewCon1 --->ViewCon2 ---> Tab 2 ---> Tab 3

Heres an example. If we navigate to ViewCon2 in Tab 1, tap on Tab 2, and return to Tab 1, we will see that the we will return to ViewCon2. What I want to do is have the Tab Bar Controller default to ViewCon1. I tried creating a subclass of UITabBarController, but I couldn't really find the correct set of APIs that I was looking for. Does anyone have any suggestions?

Upvotes: 0

Views: 569

Answers (1)

Owen Hartnett
Owen Hartnett

Reputation: 5935

I think the call you're looking for is:

- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated; //(to move to your rootviewcontroller)

The delegate is a helper class that generally gets called when something happens in the item, i.e. when something happens in the tab bar it calls routines in the delegate. You can make the delegate be the same class as your tabBarViewController.

Upvotes: 1

Related Questions