I'm just getting started in iOS development with Xamarin and seem to have hit a road block. I'm trying to create a custom table cell to display some data. So taking prompts from various online sources (see here for example), I created a .xib file deleted the view that Xamarin automatically created and replaced it with a UITableViewCell
. I added a few labels to my cell, I registered my cell with RegisterNibForCellReuse
and set up my class that inherits from UITableViewSource
to return my custom cell when appropriate. So far so good.
The problem starts when I take any of the controls in my custom cell and try to create an outlet. In XCode create the outlet and everything looks okay. Back in Xamarin I can see it's automagically created a property for it.
[Register ("MyCustomCell")]
partial class MyCustomCell
{
[Outlet]
MonoTouch.UIKit.UILabel MyLabel { get; set; }
void ReleaseDesignerOutlets ()
{
if (MyLabel != null) {
MyLabel.Dispose ();
MyLabel = null;
}
}
}
But when I try and run the code I get a runtime error saying This class in not key value coding-compliant for key the key MyOutlet
Any idea what might be happening? The Xamarin docs suggests a possible cause here, but I'm not sure it's relevant. I don't see anything like that in any of the designer files Xamarin has created and they've all been fine. I tried replacing the property definition above with one that uses the Connect
attribute instead of Outlet
and uses GetNativeField
and SetNativeField
, but I see the same result.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…