1

I want screen 1 to be shown when tabbaritem 1 is clicked and if I change some settings, i go to different view, , when I click the tabbaritem 1 again I want to show screen 2.

I have a UITabbar based app and the MainWindow.xib has different tabs loaded before with views.

How do I change it programmatically?

Please help

iOSDev
  • 3,617
  • 10
  • 51
  • 91

3 Answers3

1

just put the code for the views to be created in the method viewWillAppear instead of viewDidLoad. This is being called each time go go back to your tab 1

user387184
  • 10,953
  • 12
  • 77
  • 147
0

Turn MainWindow or AppDelegate into UITabBarDelegate, than use - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item to caught tab selections. When tab you need is selected, use image property of UITabBarItem to set image you like.

Praveen S
  • 10,355
  • 2
  • 43
  • 69
Valeriy Van
  • 1,851
  • 16
  • 19
0

Implement below method in your App Delegate

- (void)tabBarController:(UITabBarController *)controller willBeginCustomizingViewControllers:(NSArray *)viewControllers {

    UINavigationController *nc;
    nc = viewController;

    if(controller.selectedIndex == 3){
        [[nc.viewControllers objectAtIndex:0] replaceSubView];
    }
}

Here, if(controller.selectedIndex == 3)

3 = your viewcontroller index in which you want to change subview.

And "replaceSubView"

is your method in view controller in which you want to change subview.

Let me know in case of any difficulty.

Cheers.

Nishant B
  • 2,897
  • 1
  • 18
  • 25
  • everytime im adding a new subview while changing tabs..that is disturbing the images height and tabbar is hidden...please help – iOSDev Sep 21 '11 at 04:54
  • I am not getting you properly. You tabbar is hidden, then how will you click on it? – Nishant B Sep 21 '11 at 10:45