views:

44

answers:

2

Hello,

I am working on an application with a LoginViewController and a TabBarViewcontroller.

When the application is ran, I add the LoginViewController as a subView of window in the delegate. Once the login is ok, I remove the LoginViewController (removeFromSuperView) and add the TabBarViewController instead as a subview of windows.

This works fine.

In one of the tab of the TabBar I have a view containing a button to disconnect the user. When clicking on the button it performs the opposite than what described above: - remove the TabBarViewcontroller from the superView - add the loginViewController instead.

This works also fine except for 2 things:

  • when I login again, I get directly on the last tab I used (the one with the disconnect button) when I'd like to get to the first one

  • If I login with another user, the TabBarController is not refreshed (I see the data of the previous user... kind of dangerous:) ).

Well, those 2 things seems to be related to the same problem, the TabBarViewController is not unloaded and reloaded. Could you please help on how to do this ?

Thanks a lot, Luc

A: 

Maybe you should release your tabBarController when disconnecting and allocate it when connecting.

Charter
Hello, is there any problem to perform this action even if the tabBarcontroller was first allocated in IB ?
Luc
You may have to re-wire your outlets programmaticaly
Charter
ok, but I mean I still initilize it in IB at first place ? and then de-allocate and re-allocate when I need it ?
Luc
Yes you can do it that way or instantiate it programmatically.
Charter
A: 

I post an NSNotification to solve this problem, your view controller can observe this and reload the tabController as needed.

cory.m.smith
hello, what do you mean by reload ? thanks a lot, Luc
Luc