Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black Screen when using a Login page #79

Open
ludiaz opened this issue Nov 7, 2017 · 3 comments
Open

Black Screen when using a Login page #79

ludiaz opened this issue Nov 7, 2017 · 3 comments

Comments

@ludiaz
Copy link

ludiaz commented Nov 7, 2017

Hello,

Here is my code:

AppDelegate.cs

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    Window = new UIWindow(UIScreen.MainScreen.Bounds);

    if (isAuthenticated)
    {
        Window.RootViewController = new RootViewController();
    }
    else
    {
        Login screenLogin = new Login();
        screenLogin.OnLoginSuccess+= ScreenLogin_OnLoginSuccess
        Window.RootViewController = screenLogin ;
    }

    Window.MakeKeyAndVisible();

    return true;
    }

private void ScreenLogin_OnLoginSuccess(object sender, EventArgs e)
{
    isAuthenticated = true;
    Window.RootViewController = new RootViewController();
    Window.MakeKeyAndVisible();
}

RootViewController.cs

public partial class RootViewController : UIViewController
{
    public SidebarController SidebarController { get; private set; }
    public NavController NavController { get; private set; }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        NavController = new NavController();
        NavController.PushViewController(new Home(), false);

        SidebarController = new SidebarController(this, NavController, new Menu());
    }
}

My Login screen is a UIViewController. NavController is a class that inherits from UINavigationController. The fundamental is: if user is not authenticated, so, i show the login page. When the user enter the correct credentials, i call the event 'OnLoginSuccess', that is signed in AppDelegate. So, i change the isAuthenticated var to true and set my RootViewController class as Window.RootViewController and call Windows.MakeKeyAndVisible();

When i testing this code at emulator, works fine (iphone 5s, iphone 6s+, ipad pro 9.7). But, in a real device (iphone 6 and iphone 6s) only appears a Black Screen after the login.

All real devices are using iOS 11.1 and 11.0.3.

I'm little bit frustrated.

Thanks for the help!

@jdehlin
Copy link
Collaborator

jdehlin commented Nov 7, 2017

It doesn't seem like something related to Sidebar. Have you tried it with just a normal UIViewController?

@ludiaz
Copy link
Author

ludiaz commented Nov 8, 2017

Hi!
I'm using the examples of https://github.com/jdehlin/Xamarin-Sidebar/tree/master/iOS as base to my code.
My RootViewController looks like very much as that you use in yourr examples.
Except, that i not use Xamarin.Forms. I'm using Xamarin.IOS. My RootViewController inherits of UIViewController, and your example use a PageRenderer. I don't know if that makes some diference. Maybe. I'm investigating and testing different scenarios to have a solid conclusion.

@shanusingh3
Copy link

This logic worked in my case. In AppDelegate class.

In FinishedLaunching() method put this.

if (!VersionTracking.IsFirstLaunchEver) { var tabBarController = new RootViewController(); SetRootViewController(tabBarController, false); } else { UIStoryboard FirstOnboarding = UIStoryboard.FromName("FirstOnboarding", null); var tabBarController = GetViewController(FirstOnboarding, "MainOnBoard"); SetRootViewController(tabBarController, false); }

Now,

//To Set the Root View Controller public void **SetRootViewController**(UIViewController rootViewController, bool animate) { if (animate) { var transitionType = UIViewAnimationOptions.TransitionFlipFromRight; Window = new UIWindow(UIScreen.MainScreen.Bounds); Window.RootViewController = rootViewController; UIView.Transition(Window, 0.5, transitionType, () => Window.RootViewController = rootViewController, null); Window.MakeKeyAndVisible(); } else { Window = new UIWindow(UIScreen.MainScreen.Bounds); Window.RootViewController = rootViewController; Window.MakeKeyAndVisible(); } }

public UIViewController **GetViewController**(UIStoryboard storyboard, string viewControllerName) { return storyboard.InstantiateViewController(viewControllerName); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants