运行故事板项目时,Monotouch键值编码兼容崩溃

时间:2014-01-21 11:27:45

标签: ios xcode xamarin.ios xamarin xamarin-studio

在我向故事板添加一个简单的按钮或组件,然后运行调试后,我收到一条消息,指出存在键值编码问题。如果我清理解决方案,它的构建就可以,但是如果我添加另一个组件,我会再次得到相同的错误。

enter image description here

1 个答案:

答案 0 :(得分:1)

看到问题后编辑

问题似乎出现在Xamarin Studio上 - 这是Xamarin的Bugzilla上的bug report #15002。我将在示例中添加github repository来重现问题。它仅在设备上发生,而不在模拟器上发生。


旧答案

将正在运行的实例附加到AppDelegate时会出现问题。您的AppDelegate.cs文件可能包含未注册的类。尝试验证您的文件内容是否与此类似:

特别是这部分:

    [Register ("AppDelegate")]
    public partial class AppDelegate : UIApplicationDelegate

完整档案:

using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace StoryBoardTables
{
    // The UIApplicationDelegate for the application. This class is responsible for launching the
    // User Interface of the application, as well as listening (and optionally responding) to
    // application events from iOS.
    [Register ("AppDelegate")]
    public partial class AppDelegate : UIApplicationDelegate
    {
        // class-level declarations
        UIWindow window;
        PaintCodeViewController viewController;
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            viewController = new PaintCodeViewController ();
            window.RootViewController = viewController;
            window.MakeKeyAndVisible ();

            return true;
        }
    }
}