简体   繁体   中英

Xamarin iOS Simulator Showing Black Screen

I am running 2015 Visual Studio with Xamarin. When I launch the iOS Simulator, it is showing a black screen on the simulator. I am using a Storyboard with a Navigation Controller.

  • I have the Main Interface set to the my storyboard.
  • Size Class - Any / Any
  • I have restarted the simulator, ran "Reset Content and Settings"

AppDelegate code (only method with contents.):

    public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        // create a new window instance based on the screen size
        Window = new UIWindow(UIScreen.MainScreen.Bounds);
        // If you have defined a root view controller, set it here:
        Window.RootViewController = new Controllers.RegistrationController();
        // make the window visible
        Window.MakeKeyAndVisible();
        return true;
    }

我的故事板

You could try something like :

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    // create a new window instance based on the screen size
    Window = new UIWindow(UIScreen.MainScreen.Bounds);

    string storyboardName = "Main";
    UIStoryboard storyboard = UIStoryboard.FromName(storyboardName, null);
    // if it is the first viewcontroller
    UIViewController vc = storyboard.InstantiateInitialViewController(); 

    // If you have defined a root view controller, set it here:
    Window.RootViewController = vc;
    // make the window visible
    Window.MakeKeyAndVisible();
    return true;
}

if your storyboard is called Main.stroyboard try using this:

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    return true;
}

I tested both of these options and both should work when your Storyboard is called Main

You need to have a segue from your UINavigationController to an UIViewController with the content in it. If you don't have a segue then your app is going to show a black screen since the app doesn't think it has any content.

If I understand you correctly, your storyboard may look like this: Storyboard 1

And you need to create a segue between the two view controllers so that your storyboard looks like this with the segue-arrow between the two view controllers: Storyboard 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM