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.
I was having this problem for a while in my case it turned out to be a problem relating to the build process. The following fixed it for me :
Right-click your project, select 'Options' then 'iOS Build' under the 'Build' sub-heading, add -f to 'Additional mtouch arguments' and rebuild.
I was running into the same issue, and finally I did Product->Clean within XCode, and it solved my problem.
Right-click your project, select 'Options' then 'iOS Build' under the 'Build' sub-heading, add -f to 'Additional mtouch arguments' and rebuild.
In my case, I was creating actions for a few buttons, and I accidentally made an outlet, instead of an action. I just deleted the @IBOutlet line.
My error was:
this class is not key value coding-compliant for the key Button_Twitter_Clicked.'
Again, in my case, I found my solution from:
http://www.tech-recipes.com/rx/52021/how-do-i-fix-the-issue-this-class-is-not-key-value-coding-compliant-for-the-key-in-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 :)
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With