Hello,
I am trying to work with a UIImageView programmatically and can't get it to appear on the screen. In my header I have the following lines:
@interface myClass : UIView {
UIImageView *imageView;
}
@property (nonatomic, readonly) IBOutlet UIImageView *imageView;
Then in my viewWillAppear
I have the following:
self.imageView.frame = CGRectMake(10, 10, 72, 72);
self.imageView.backgroundColor = [UIColor redColor];
[self.imageView setImage:[UIImage imageNamed:@"test-image.png"]];
[containerView addSubview:self.imageView];
And this doesn't work at all. If I add the following lines in viewWillAppear
I can get a UIImageView to appear:
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"blue_button_bg.png"]];
[containerView addSubview:imgView];
So I can't make sense of why instantiating a UIImageView would work but using the class's ivar would not. What am I doing wrong here?
Thank you very much!