views:

86

answers:

1

I've created a custom class inheriting from UILabel. I placed a UILabel in my nib and set the class of the label to my custom class. However, when the viewDidLoad method is called, the view is of the class UILabel instead of my custom class.

Any ideas?

A: 

I was able to create an instance of my CustomLabel in a test project. What I did differently was instead of dragging a UILabel, I pulled in an instance of CustomLabel into the view.

I implemented awakeFromNib against a target for the latest sdk as follows.

-(void)awakeFromNib
{
    [self setText:[NSString stringWithFormat:@"%@",[self class]]];
}

- (void)drawTextInRect:(CGRect)rect // called as expected
{
    NSLog(@"drawTextInRect: called");
    [super drawTextInRect:rect];
}

Couple of mysteries... I implemented init and initWithFrame in CustomLabel, neither was called by the machinery that loads the view from the nib.

falconcreek