2
votes

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,

enter image description here

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

2
Just try recreate it. self.tabBarController = [[UITabBarController alloc] init]; and init with your data items - Pavel Petrovich
i'm writing app without interface builder - Pavel Petrovich
assigning to property with read only attribute not allowed, when i tried self.tabBarController = [[UITabBarController alloc] init]; @luther - rakeshNS

2 Answers

1
votes

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

0
votes

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.