简体   繁体   中英

The view controller of a uitabbarcontroller not getting refreshed

i have a uitabarcontroller in which 3 view controller are added .in the 3rd tab i have a picker view which selects some settings based on which data in the 2nd tab changes.When i migrate into 2nd tab the data is not getting refreshed as i have the same old data.How can i refresh the data in the 2nd tab.

NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:3];

MainViewController *mainview;
mainview = [[MainViewController alloc] init];
mainview.tabBarItem.image=[UIImage imageNamed:@"pipeline.png"];
mainview.title=@"Pipeline";
navigationController = [[UINavigationController alloc] initWithRootViewController:mainview];
[localControllersArray addObject:navigationController];
[navigationController release];
[mainview release];
tabBarController.viewControllers = localControllersArray;
    [self.view addSubview:tabBarController.view];

This is the way i have added 3 view controller to my tab controller in a view controller.

first of all, as I remember, I had no problems with methods viewDidAppear:(BOOL)animated and viewWillAppear:(BOOL)animated in the tabbar application. another possible solution is to make some methos in your second controller like updateUI, so you can call it from yout tabbar's delegate method

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

The second variant is rather ugly, but it will work. try to check what is wrong with your viewDidApear: method. maybe you should transfer some UI changes to viewWillApear: method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM