UIImage for UIImageView is nil
- by yeesterbunny
I'm having problem displaying UIImage in UIImageView. I looked all over stackoverflow for similar questions, but none of the fixes helped me.
The image is indeed in my bundle
File Inspector - Target Membership is checked for the image
IBOutlet is connected (I have tried both using IBOutlet and doing it programmatically)
Both png nor jpg works
Here's the code for using Interface Builder -
//@property and @synthesize set for IBOutlet UIImageView *imageView
- (void)viewDidLoad
{
[super viewDidLoad];
NSAssert(self.imageView, @"self.imageView is nil. Check your IBOutlet connection");
UIImage *image = [UIImage imageNamed:@"banner.jpg"];
NSAssert(image, @"image is nil");
self.imageView.image = image;
}
This code will terminate with NSAssert, printing in the console that 'image is nil'.
I also tried selecting the Image directly from the attributes inspector:
However it still doesn't show the image (still terminates with NSAssert - 'image is nil').
Any help or suggestions will be greatly appreciated.
Thanks