简体   繁体   中英

Resetting Tab bar controller's view controllers

In my Application I have creted view controllers for Tab Bar using XIB. I mean I added view controllers in tab bar using XIB. See picture,

在此处输入图片说明

So my application is like this. I have a log out functionality that will show login page. From Login page I have displayyed tab bar as

    [self.view addSubview tabBarController.view];

When I log out I simply remove this tab bar and show login screen as

    [self.tabBarController.view removeFromSuperView];

Then It will show login screen. When I login again, The view controllers inside tab bar is not reset. I mean If I have showed some data like names in table view, It will be there as it is when I logged in again (some time I login as different user and I get details for previous user.). I tried

    self.tabBarController.viewControllers = nil;

to reset all view controllers, but it not works any more. I think each time When I log in all view controllers should call ViewDidLoad: , currently it is calling viewWillAppear: . So please let me know how could I resolve this issue

I think since you are not using a fresh object once you sign out and sign in again, it is showing you with the last stage. Try initializing your controller object after you have logged in may work for you.

Let me know if you find any problem further.

Cheers Tarun

All it's troubles because you use Interface Builder. Ok, try to explain. In your class like MyViewController.m ypu need set property like this:

@interface MyViewController : UIViewController
{
    IBOutlet UITabBarController *mytabbar;
}

In IB (Interface Builder) you need set mytabbar property name for your UITabBarController. After that you can rectreate this variable, because you have pointer to this variable.

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