UIImage for UIImageView is nil
Posted
by
yeesterbunny
on Stack Overflow
See other posts from Stack Overflow
or by yeesterbunny
Published on 2012-10-13T21:34:35Z
Indexed on
2012/10/13
21:36 UTC
Read the original article
Hit count: 172
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
© Stack Overflow or respective owner