菜鸟教程小白 发表于 2022-12-13 14:53:35

c# - 应用程序启动结束时的 Xamarin iOS Root View Controller


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

<pre><code>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
</code></pre>

<p>这是由 <code>Main.cs</code> 类中的 UIApplication.Main 调用引起的</p>

<pre><code>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 &#34;AppDelegate&#34;
            // you can specify it here.
            UIApplication.Main(args, null, &#34;AppDelegate&#34;);
      }
    }
}
</code></pre>

<p>我完全无处可寻 - 以前有没有人遇到过这种情况?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我遇到了同样的错误,我的问题是我在设置 MainPage 之前运行了 async/await 方法。所以,我只是移动了 MainPage = new MainPage();在 InitializeComponent() 之后;现在可以使用了。</p></p>
                                   
                                                <p style="font-size: 20px;">关于c# - 应用程序启动结束时的 Xamarin iOSRoot ViewController ,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/42150467/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/42150467/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: c# - 应用程序启动结束时的 Xamarin iOS Root View Controller