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

Filed under:
|
|

I'm having problem displaying UIImage in UIImageView. I looked all over stackoverflow for similar questions, but none of the fixes helped me.

  1. The image is indeed in my bundle
  2. File Inspector -> Target Membership is checked for the image
  3. IBOutlet is connected (I have tried both using IBOutlet and doing it programmatically)
  4. 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: enter image description here

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

Related posts about objective-c

Related posts about ios