2

In MonoTouch I have defined the following class:

using System;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using System.Drawing;

namespace MyApp
{
    public class WUILabel : UILabel
    {
        public WUILabel () : base() { this.SetDefaults(); }
        public WUILabel(NSCoder coder) : base(coder) { this.SetDefaults(); }
        public WUILabel(NSObjectFlag t) : base(t) { this.SetDefaults(); }
        public WUILabel(IntPtr handle) : base(handle) { this.SetDefaults(); }
        public WUILabel(RectangleF frame) : base(frame) { this.SetDefaults(); }

        private void SetDefaults()
        {
            this.Font = UIFont.FromName("AmericanTypewriter", 15f);
            this.TextColor = UIColor.Black;
        }
    }
}

In Interface Builder, I am setting the "Class" attribute of my label to "WUILabel".

When I run the application, the Application Output contains the error "Unknown class WUILabel in Interface Builder file." Has anyone successfully gotten this to work, or can anyone tell me what I'm doing wrong?

ctacke
  • 66,480
  • 18
  • 94
  • 155
Rodney Willis
  • 273
  • 3
  • 7

1 Answers1

2

You have to decorate your class with the RegisterAttribute.

Check this answer.

Community
  • 1
  • 1
Dimitris Tavlikos
  • 8,170
  • 1
  • 27
  • 31