James
James

Reputation: 2999

UITabBarController inside a UIViewController = viewDidAppear: not called

I start off with a login screen. Then after the user logs in I load a Viewcontroller with UITabBArController in it. The problem is viewdidAppear: does not get called for any of the individual viewControllers in the tabBarController.

I have a feeling that this is not the best programming practise so does anyone have any ideas how to improve the structure of my code or how to fix my problem ?

Upvotes: 3

Views: 1665

Answers (4)

Matej Ukmar
Matej Ukmar

Reputation: 2245

I had a problem because I was subclassing also UITabBarControler where I have overridden viewDidAppear without calling [super viewDidAppear:...]

After calling this, viewDidAppear was called also inside sub-view-controller.

Upvotes: 3

Danilo Campos
Danilo Campos

Reputation: 6479

I'd guess your trouble here comes from incorrect use of UIViewController and UITabBarController.

UITabBarController exists as a container for multiple view controllers. It probably should not, itself, be contained. It's designed to sit at the top of a view controller hierarchy. So step one is probably to re-arrange your application so that the UITabBarController is no longer under anything else and see if that straightens you out.

After that, slev's approach of presenting the login view sounds like the right one.

Upvotes: 3

albianto
albianto

Reputation: 4152

You could try to manually call viewdidAppear on the subviewcontrollers: when it's called on the rootviewcontroller also call subviewcontroller's ones manually.

Upvotes: 0

justin
justin

Reputation: 5831

Why not make an app which is TabBarController-based, then immediately call a modal screen at app start (for your login)? After you're done with the login, just dismiss it to allow the TabBarController to become key window.

Upvotes: 2

Related Questions