Domanda

I've been struggling with this a long time now, so I finally gave up on trying to find the answer and decided to ask it right away.

On my app I have a user log in page. The app has a TabBarViewController that has some NavigationControllers in it's items.

My last effort was to put the login screen embedded on a NavigationBarController and make it the Initial View Controller, as in the picture below.

enter image description here

When the app is launched, if the user is logged in the LogInViewController 'segues' to the TabBarController and everything is fine. When the user logs out in the ProfileViewController, there's a segue in this ViewController 'segueing' to the initial view controller.

In the other hand, if no user is logged in, the LogInViewController presents a view so that the user can insert username and password. If credentials are correct the LogInViewController 'segues' to the TabBarController. The problem is that at this point, even if the app is still working good, i get the following warning:

Warning: Attempt to present TabBarViewController: 0xa19a670 on UINavigationController: 0xa526370 while a presentation is in progress!

So I assume this is not the best way to handle all this LogIn/LogOut process.

My question is, where should I put the LogInScreen in the hierarchy? If by any chance my layout/hierarchy is correct, how to make the warning go away?

È stato utile?

Soluzione

You should make your Home screen as your rootViewController and in once your application starts or become active, you can check if user is logged in or not, if not then present the LoginScreen Modally, it will avoid the mess with other NavigationController or TabBarController

Alternate could be to put all the ViewControllers in a MutbaleArray and set the current Index of TabBarController according to the view you want to show? if you don't want to show the LoginScreen after user Logged in, just remove it from your MutableArray, check my answer here, it might help your cause

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top