Still getting my head around things here. I'm not even close, but anyways.... I have a TabBar application created from Xcode. It works I have three tab views, that I know how to manipulate, etc.
I'd like to put a 'login' nib file in front of this whole thing, requiring a user to answer a (hardcoded for now) username and password. If you get that right, then, render the tab portion, allowing them to click around.
I have another application that I've written that does the username and password part, I'm having trouble taking the logic from there, and putting it in front of the TabApplication piece.
Anyone have any suggestions?
In your AppDelegate, at the end of the application didFinishLaunchingWithOptions
method you'll see this:
[window addSubview:tabcontroller.view];
[window makeKeyAndVisible];
return YES;
Simply initialize your login view controller and add it after the tabcontroller, like this:
initialScreenViewController = [[InitialScreenViewController alloc] init];
[window addSubview:tabcontroller.view];
[window addSubview:initialScreenViewController.view];
[window makeKeyAndVisible];
return YES;
In you login viewcontroller, after authenticating the user you can hide it like this:
[self.parentViewController.view setHidden:YES];
which allows you to show it again if you have a logout feature.
The standard way is the following:
UIViewController
subclass which manages that.Present that view modally in the app delegate in application:didFinishLaunchingWithOptions:
by calling
LoginController*loginController= ... ; // create the view controller for the login screen
[self.tabController presentModalViewController:loginController animated:YES];
This way, the animation between the transition etc. is automatically handled.
You can later dismiss it after you successfully logs in. It can be done from inside the LoginController
by
[self.parentViewController dismissModalViewControllerAnimated:YES];
However, I often need to do additional setup once the logging-in is done. So, I would first tell the app delegate that the login is done, and then perform
[self.tabController dismissModalViewControllerAnimated:YES];
from the app delegate. Then I can perform additional tasks there.
To communicate back to the app delegate, I would use NSNotification
, but that might be a bit difficult for you.
One way which might be easier to understand (but uglier to my taste) is to define a method, say loginDone
in the app delegate.
Then, inside the LoginViewController
, you can do
MyAppDelegate*appDelegate=[[UIApplication sharedApplication] delegate];
[appDelegate loginDone];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With