[英]Xamarin.forms iOS Black Screen after launching (Xamarin Visual Studio 2022)
我有一个正在开发很长一段时间的应用程序,我想将它“移植”到 iOS。当我启动它时,启动画面出现并且工作正常。 在启动画面之后,它变成黑屏,但不会崩溃。 如果我创建一个新应用程序并尝试运行它,它会完美运行。 我不使用任何故事板,我正在尝试部署到 iPhone SE。 它目前有 iOS 15.3。 什么会导致这个?
编辑:这是应用程序打开的第一页的代码:
<?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>
我有一个应用程序正在开发很长一段时间,我想将它“移植”到 iOS。
您想将您的应用移植到Xamarin.Forms
或Xamarin.iOS
FinishedLaunching
中的代码与这两种方式完全不同。
如果Xamarin.Forms
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
如果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
}
使用这个我发现 info.plist 文件中有几行导致了这个问题。 您只需要从 info.plist 中删除这些行,它就可以正常工作。
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
</dict>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.