无法实例化 UIMainStoryboardFile 的默认视图控制器

Failed to instantiate the default view controller for UIMainStoryboardFile

我正在使用 Xamarin 和 MvvmCross 6.4.2 编写一个小型示例应用程序。我完成了 Xamarin.Android 版本,现在开始 Xamarin.iOS 版本。我为第一个屏幕创建了一个视图控制器:

public class SignInViewController : MvxViewController<SignInViewModel>
{
    public SignInViewController() : base(nameof(SignInViewController), null)
    {
        
    }

    public override void ViewDidLoad()
    {
        // never gets called...

        base.ViewDidLoad();
    }
}

当我 运行 应用程序时,我只是看到一个空白屏幕,并且 ViewDidLoad 从未被调用。在应用程序输出中显示:

Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?

我的 Main.storyboard 是空白的,我试图在 Xcode Interface Builder 中修改它以将我的 SignInViewController 设置为入口点,但我不知道如何做。

Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?

这个错误是由于你的情节提要中的一个简单错误造成的。当您的应用程序启动时,iOS 需要准确地知道首先需要显示哪个视图控制器——称为默认视图控制器。

要修复它,请将 ViewController 添加到您的 Main.Storyboard 并将其设置为 Inital View Controller

参考:how-to-fix-the-error-failed-to-instantiate-the-default-view-controller-for-uimainstoryboardfile

并且您的项目中有两个SignInViewController

使用这个:

public partial class SignInViewController : UIViewController
{
    public SignInViewController (IntPtr handle) : base (handle)
    {
    }

    public override void ViewDidLoad()
    {
        // never gets called...

        base.ViewDidLoad();

        View.BackgroundColor = UIColor.Red;
    }
}

更新: