Home > Back-end >  Xamarin.forms iOS Black Screen after launching (Xamarin Visual Studio 2022)
Xamarin.forms iOS Black Screen after launching (Xamarin Visual Studio 2022)

Time:02-08

I have an App that's in development for quite a while now and I wanted to "port" it to iOS. When I start it, the splash screen appears and it works fine. After that splash screen it turns into a black screen, but it doesn't crash. If I create a New Application and try to run it it works perfectly. I don't use any storyboards and I'm trying to deploy to a iPhone SE. It currently has iOS 15.3 on it. What could cause this?

EDIT: Here is the Code of the first page that the App opens:

<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Easy_Learn.Pages.Shellpage"
            xmlns:pages="clr-namespace:Easy_Learn.Pages"
            xmlns:local="clr-namespace:Easy_Learn"
            xmlns:viewtemplates="clr-namespace:Easy_Learn.ViewTemplates"
            xmlns:windows="clr-namespace:Xamarin.Forms.PlatformConfiguration.WindowsSpecific;assembly=Xamarin.Forms.Core"
            windows:Application.ImageDirectory="Assets"
            FlyoutHeaderTemplate="{DataTemplate viewtemplates:FlyoutHeader}"
            Shell.TabBarIsVisible="False"
            Shell.TabBarForegroundColor="{StaticResource backGroundColor}"
            Shell.BackgroundColor="{StaticResource backGroundColor}"
            Shell.TitleColor="{StaticResource textColor}"
            Shell.ForegroundColor="{StaticResource textColor}">
    <ShellContent ContentTemplate="{DataTemplate local:MainPage}" Title="Lernen" Icon="LightBulb.png"/>
    <FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
        <ShellContent ContentTemplate="{DataTemplate pages:AllVocabs}" Title="Alle Vokabeln" Icon="Book.png"/>
        <ShellContent ContentTemplate="{DataTemplate pages:deklkonj}" Title="Deklinationen" Icon="table.png"/>
        <ShellContent ContentTemplate="{DataTemplate pages:Konjugationen}" Title="Konjugationen" Icon="table.png"/>
        <ShellContent ContentTemplate="{DataTemplate pages:adjectives}" Title="Adjektive" Icon="table.png"/>
        <ShellContent ContentTemplate="{DataTemplate pages:profile}" Title="Profil" Icon="account.png"/>
    </FlyoutItem>
</Shell>

CodePudding user response:

I have an App that's in development for quite a while now and I wanted to "port" it to iOS.

Do you want to port your app to Xamarin.Forms or Xamarin.iOS?

The code in FinishedLaunching is totally different with the two ways .

If Xamarin.Forms

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    global::Xamarin.Forms.Forms.Init();
    LoadApplication(new App());

    return base.FinishedLaunching(app, options);
}

If Xamarin.iOS

//AppDelegate (< iOS13)
[Export ("application:didFinishLaunchingWithOptions:")]
public bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{          
   Window = new UIWindow (UIScreen.MainScreen.Bounds);
   Window.RootViewController = new UIViewController();
   Window.MakeKeyAndVisible ();   // important 

   return true;
}
//SceneDelegate (>= iOS13)
[Export ("scene:willConnectToSession:options:")]
public void WillConnect (UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions)
{
    Window = new UIWindow(scene as UIWindowScene);
    Window.RootViewController = new UIViewController();
    Window.MakeKeyAndVisible ();   //important
}

CodePudding user response:

Using this I found that there were a few lines in the info.plist file that cause this issue. You just need to remove these lines from your info.plist and it works fine.

 <key>UIApplicationSceneManifest</key>
 <dict>
     <key>UIApplicationSupportsMultipleScenes</key>
     <true/>
 </dict>

  •  Tags:  
  • Related