views:

278

answers:

2

Hi,

Can any one help me, when i am using my UITabBarController delegate it is not working..

I called a delegate method like this..

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{

 [self.navigationController popToRootViewControllerAnimated:NO];
}
A: 

Read the documents to get a deeper understanding of the relationships between navigation controllers, tabBar controllers, and the view and navigation hierarchy.

Then review the code you've provided. Which view/controller is the container? You are popping the navigationController of self, which is not the same as the tabBarController. I don't think you actually need this method if you are looking to switch between tabs.

Try commenting out this method. It is an optional method in the UITabBarController delegate protocol. If you comment it out, you should get the default behavior of the tab controller, which should be to select the appropriate viewController and switch to the new view.

You typically only need to use this method if you want some action taken as you switch between view controllers.

Chip Coons
A: 

This might help you

-(void)applicationDidFinishLaunching:(UIApplication *)application {

tabBarController.delegate=self;

// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];

}

raaz