IBOutlet is nil inside custom UIView (Using STORYBOARD)

Override awakeFromNib in your view - this is the first lifecycle method to be called after the IBOutlets have been assigned and is the right place for your code.


initialize them in awakeFromNib:

- (void)awakeFromNib
{
    //init code
}

I just had the exact same problem and the solution is really easy:

You're accessing myImage to soon - that's it.

Withing -(id) initWithCoder:(NSCoder *)aDecoder{ and - (id)initWithFrame:(CGRect)frame the UIView is not already drawed. So myImage is not initalized yet.

You can test it if you add a UIButton and an IBAction and do something like this:

- (IBAction)buttonClicked:(id)sender {
    NSLog(@"%@",myImage);
}

And you'll see how myImage is not nil anymore.