Using MonoTouch I add a LogonViewController to the Window and show it on FinishedLaunching:
window = new UIWindow(UIScreen.MainScreen.Bounds);
window.RootViewController = new LogonViewController();
window.MakeKeyAndVisible();
In the LogonViewController, how do I add the main VC, called MainViewContoller and remove the LogonViewController? (This is the action that will happen once the user is logged in.)
Even if it's possible to replace the window.RootViewController, that's not how it's usually done. Most of the time, you define your RootViewController and handle your navigation, including login, from there. That's at least how I do it.
//AppDelegate.cs
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.RootViewController = new MainViewController ();
window.MakeKeyAndVisible ();
return true;
}
//MainViewController.cs
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
if (not_logged_in)
PresentViewController (new LoginViewController (), true, ()=>{});
}
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