1

For the past two days I've been scavenging the xamarin forums and stackoverflow for a solution to my problem. I keep getting an exception in my Main.cs file "setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key HeaderLabel. I am relatively new to developing with xamarin.

So far I have attempted all tips from this link and no success. I did Build -> Clean -> Rebuild, I went into the solutions folder and deleted all the Obj and Bin folders. I deleted the application from my simulator. The error still persists. I also attempted to relink the .xib file to its .cs owner file by removing the ownership via the widget's property field, building, assigning the ownership back again and building. https://forums.xamarin.com/discussion/11750/this-class-is-not-key-value-coding-compliant-for-the-key?

I did find two outlet properties in my xml that should not have been there, I deleted them as the following post provide as their solution and build the ios solution and I still get the same exception. Resolve "'NSUnknownKeyException', reason:This class is not key value coding-compliant for the key X” exception

Another fellow developer working with me noticed that when he checked out my branch, the background of the label was reset to its default white color and the app would build and run in the simulator showing nothing (white font on top of missing purple background) and it wasn't until he changed the background that he got the error.

The last option which I've not attempted because I can't find myself doing this every time it occurs, is that a user who experienced similar issues resorted to deleting the ViewController cs/designer/xib files and starting from scratch. I am trying to avoid this situation as it is not very viable. Any help would be appreciated. If any other code is images is required just let me know and I'll provide them as needed. I don't know what other option exists to solve this problem. Thanks.

Key value pair exception

This is my WelcomeViewController.xib

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
    <dependencies>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
    </dependencies>
    <objects>
        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="WelcomeViewController">
            <connections>
                <outlet property="HeaderLabel" destination="5" id="name-outlet-5"/>
            </connections>
        </placeholder>
        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
        <view contentMode="scaleToFill" id="2">
            <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
            <subviews>
                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Welcome" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="5" translatesAutoresizingMaskIntoConstraints="NO" fixedFrame="YES">
                    <rect key="frame" x="0.0" y="0.0" width="375" height="53"/>
                    <fontDescription key="fontDescription" type="system" pointSize="24"/>
                    <color key="textColor" colorSpace="calibratedRGB" red="1" green="1" blue="1" alpha="1"/>
                    <nil key="highlightedColor"/>
                    <color key="backgroundColor" colorSpace="calibratedRGB" red="0.34901960784313724" green="0.00784313725490196" blue="0.43137254901960786" alpha="1"/>
                </label>
            </subviews>
        </view>
    </objects>
    <simulatedMetricsContainer key="defaultSimulatedMetrics">
        <simulatedScreenMetrics key="destination" type="retina47"/>
    </simulatedMetricsContainer>
</document>

WelcomeViewController.Designer.cs

namespace ConnectContacts.Ios.Views.View 
{
    [Register ("WelcomeViewController")]
    partial class WelcomeViewController
{
    [Outlet]
    [GeneratedCode ("iOS Designer", "1.0")]
    UIKit.UILabel HeaderLabel { get; set; }

    void ReleaseDesignerOutlets ()
    {
        if (HeaderLabel != null) {
            HeaderLabel.Dispose ();
            HeaderLabel = null;
        }
    }
}

WelcomeViewController.cs

using ConnectContacts.Business.ViewModels;
using MvvmCross.iOS.Views;

namespace ConnectContacts.Ios.Views
{
    public class WelcomeViewController : MvxViewController<WelcomeViewModel>
    {
        public WelcomeViewController() : base("WelcomeViewController", null)
        {
        }
    }
}

0 Answers0