OGeek|极客世界-中国程序员成长平台

标题: c# - 在 iOS 设备上启动屏幕后,Forms 应用程序崩溃 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 11:33
标题: c# - 在 iOS 设备上启动屏幕后,Forms 应用程序崩溃

我有一个 Xamarin Forms 应用程序,可以在 Android 和 iOS 模拟器上完美运行,但如果我尝试在 iOS 设备上部署它,它会在我看到我的第一个屏幕时崩溃。

有时它会在日志中写入 MT1107 错误,但有时不会

这是我的 iOS 设备日志: http://pastebin.com/uGp5K7Pg



Best Answer-推荐答案


检查 PasteBin 的第 70 行:

Sequence contains no elements (System.InvalidOperationException)
at System.Linq.Enumerable.Last[UIViewController] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
at Xamarin.Forms.Platform.iOS.NavigationRenderer.<.ctor>b__0 (Xamarin.Forms.Platform.iOS.TabletMasterDetailRenderer sender) [0x00000] in <filename unknown>:0
at Xamarin.Forms.MessagingCenter+<>c__DisplayClass4`1[Xamarin.Forms.Platform.iOS.TabletMasterDetailRenderer].<Subscribe>b__3 (System.Object sender, System.Object args) [0x00000] in <filename unknown>:0

您似乎正在将 MasterDetailPage 包装到 NavigationPage 中。在 iOS(更具体地说:iPad)上,它使用 UISplitViewController,它不能嵌入到 UINavigationController 中。 Xamarin.Forms 尽可能使用 native 控件。

尝试检查设备操作系统和习语:如果您使用的是 iPad,请不要在页面周围包裹 NavigationPage

关于c# - 在 iOS 设备上启动屏幕后,Forms 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32227383/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4