I am trying to change the label with my programmatically loaded NIB. I created a class MyView which includes a UILabel* named myLabel but when I use MyView I cannot change myLabel:
MyView.h
@interface MyView : UIView
{
UIView *view;
UILabel *myLabel;
}
@property (nonatomic, retain) IBOutlet UIView *view;
@property (nonatomic, retain) IBOutlet UILabel *myLabel;
MyView.m
@implementation MyView
@synthesize myLabel, view;
- (id)initWithFrame:(CGRect)frame
{
...
So when I initialize the MyView
UIView *myView = [[MyView alloc] initWithFrame:CGRectMake(0,0,100,100)];
I cannot change the label as myLabel is not identified:
myView.myLabel.text = @"New Label Text";
I know there is some silly error in my logic or understanding of UIView.
You need to declare it as,
If you use
UIView, it is saying that it cannot find a property namedmyLabelinUIViewclass. Since you have declared this property in a subclass ofUIView, you need to use the subclass name here.