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

标题: c# - 应用程序启动结束时的 Xamarin iOS Root View Controller [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 14:53
标题: c# - 应用程序启动结束时的 Xamarin iOS Root View Controller

这真的让我陷入了困境。我为 Visual Studio 安装了 Xamarin,创建了一个空项目并连接到我的 Mac。我模拟一个 iPhone 并得到这个错误

Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: Application windows are expected to have a root view controller at the end of application launch

这是由 Main.cs 类中的 UIApplication.Main 调用引起的

using UIKit;

namespace testapp
{
    public class Application
    {
        // This is the main entry point of the application.
        static void Main(string[] args)
        {
            // if you want to use a different Application Delegate class from "AppDelegate"
            // you can specify it here.
            UIApplication.Main(args, null, "AppDelegate");
        }
    } 
}

我完全无处可寻 - 以前有没有人遇到过这种情况?



Best Answer-推荐答案


我遇到了同样的错误,我的问题是我在设置 MainPage 之前运行了 async/await 方法。所以,我只是移动了 MainPage = new MainPage();在 InitializeComponent() 之后;现在可以使用了。

关于c# - 应用程序启动结束时的 Xamarin iOS Root View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42150467/






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