这个类不是关键值编码兼容(与故事板)

我刚开始使用Xamarin开发iOS,似乎遇到了障碍。 我正在尝试创build一个自定义表格单元格来显示一些数据。 因此,从各种在线资源提示(例如,请参阅此处 ),我创build了一个.xib文件,删除了Xamarin自动创build的视图,并将其replace为UITableViewCell 。 我给我的单元格添加了一些标签,我使用RegisterNibForCellReuse注册了单元格,并设置了从UITableViewSourceinheritance的类,以在适当的时候返回我的自定义单元格。 到现在为止还挺好。

当我在我的自定义单元格中的任何控件,并尝试创build一个sockets时,问题开始。 在XCode创build出口,一切看起来不错。 回到Xamarin,我可以看到它自动为它创build一个属性。

 [Register ("MyCustomCell")] partial class MyCustomCell { [Outlet] MonoTouch.UIKit.UILabel MyLabel { get; set; } void ReleaseDesignerOutlets () { if (MyLabel != null) { MyLabel.Dispose (); MyLabel = null; } } } 

但是,当我尝试运行代码时,我得到一个运行时错误,说This class in not key value coding-compliant for key the key MyOutlet

任何想法可能会发生什么? Xamarin文档在这里提出了一个可能的原因,但我不确定它是相关的。 在Xamarin创build的任何devise器文件中,我都没有看到类似的东西,它们都很好。 我尝试使用Connect属性而不是Outletreplace上面的属性定义,并使用GetNativeFieldSetNativeField ,但是我看到了相同的结果。

我遇到这个问题有一段时间,在我的情况下,这是一个与构build过程有关的问题。 以下为我解决了这个问题:

右键点击你的项目,select“选项”,然后select“Build”子标题下的“iOS Build”,添加-f到“Additional mtouch arguments”并重build。

我遇到了同样的问题,最后我在XCode中执行了Product-> Clean,并解决了我的问题。

右键点击你的项目,select“选项”,然后select“Build”子标题下的“iOS Build”,添加-f到“Additional mtouch arguments”并重build。

就我而言,我正在为几个button创build动作,而我不小心做了一个sockets,而不是一个动作。 我刚刚删除了@IBOutlet行。

我的错误是:

  this class is not key value coding-compliant for the key Button_Twitter_Clicked.' 

再次,在我的情况下,我发现我的解决scheme:

http://www.tech-recipes.com/rx/52021/how-do-i-fix-the-issue-this-class-is-not-key-value-coding-compliant-for-the-key-在-xcode的-6 /

  - Click the "Show Find Navigator" on the left hand side - Search for the key above that gave the error, in my case it was the "Button_Twitter_Clicked" key. - Double click on the result (my case, I clicked on the View Controller:Outlet - On the right hand side, find the Key that was in the exception thrown during runtime (Has exclamation mark) (States that the view controller does not have an outlet named [outletname] - Click the X button - Recompile :) 

希望这可以帮助!

我同意理查德的回答。

你可以做的另一件事是重build项目。 是-f参数所做的。

虽然这是一个比较老的话题,但我想分享我的经验。 所以我有同样的问题,“清洁”解决scheme没有为我工作。 我的解决scheme是:1.右键单击您的项目,select“选项”2.在生成部分下selectiOS生成3.在链接器选项中select“链接所有组件”链接器的行为。