简体   繁体   English

Xamarin Forms 应用程序在 iOS 设备上出现闪屏后崩溃

[英]Xamarin Forms App crashes after splash screen on iOS device

My Xamarin Forms App works fine in Android devices, but when trying do deploy on a real iOS device it crashes after the splash screen, I said real because I can run without any problem on the simulator.我的 Xamarin Forms 应用程序在 Android 设备上运行良好,但是当尝试在真实的 iOS 设备上部署时,它在启动画面后崩溃,我说是真实的,因为我可以在模拟器上毫无问题地运行。

I try to debug the App on a real iOS device, and I found that the crash happen when the App try to load the XAML file on:我尝试在真实的 iOS 设备上调试应用程序,我发现当应用程序尝试加载 XAML 文件时发生崩溃:

private void InitializeComponent() {
        global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(LoginPage));

Please take a look at the debug steps:请看一下调试步骤:

调试开始...

崩溃发生

Regards, Pedro问候,佩德罗

I found the problem.我发现了问题。 The [XamlCompilation(XamlCompilationOptions.Compile)] was missing on the code behind C# file, and because of that some methods used by click events of controls on the XAML were not available. C# 文件背后的代码缺少 [XamlCompilation(XamlCompilationOptions.Compile)],因此 XAML 上控件的单击事件使用的某些方法不可用。 But still can't find explanation for this not happening on the simulator!但是仍然找不到模拟器上没有发生的解释!

In case it is a help to anyone, I had the same symptom for a different reason.万一它对任何人都有帮助,我出于不同的原因有相同的症状。 I am using single page simple navigation in the app in question setting MainPage to the current page in the app.我在有问题的应用程序中使用单页简单导航,将 MainPage 设置为应用程序中的当前页面。 After few days of troubleshooting, happened to notice the checkbox in Application section of info.plist, "Supports Multiple Windows" was checked.经过几天的故障排除,碰巧注意到 info.plist 的应用程序部分中的复选框,“支持多个窗口”被选中。 Unchecking this restored my app to working condition.取消选中此选项可将我的应用程序恢复到工作状态。 There were no diagnostic messages that seemed related, just a crash after splash in release mode, and a black screen in debug mode.没有似乎相关的诊断消息,只是在发布模式下启动后崩溃,在调试模式下黑屏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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