Reputation: 6662
I'm just wondering about this extremely simple thing. How do you implement one, ONE, static image to your storyboard? What i have tried so far is to have ViewController.h to
@property (strong, nonatomic) IBOutlet UIImageView *image;
and viewController.m to
_imageArray = @[@"hemla.jpg"]; //Logo for some stuff, added in resources.
image.image = [UIImage imageNamed:_imageArray[0]];
Where I either put "0" at the end, which results in nothing at all (But app is running), or "1" for a "Thread 1: Signal SIGABRT" error. (After compiling, when launching app in Simulator)
Is there a better way to implement images, or is it just me doing something wrong?
Upvotes: 1
Views: 302
Reputation: 9977
If you're using a storyboard, you don't need code at all. Just setup the imageView in the interface builder. You can set the image name there.
If you want to do it in the code, your code is right, but probably at the wrong place, e.g. the init method. The imageView has not been created at this point. You should use viewDidLoad:
or any other point after this.
Upvotes: 1