Search code examples
iosobjective-ccocoa-touchiboutlet

IBOutlet doesn't react to code


I created a UIImageView in IB and connected it to an IBOutlet:

@property (nonatomic, retain) IBOutlet UIImageView *alertImage;

However, the UIImageView doesn't react to my code at all. I tried setting the outlet and then changing a property to test:

alertImage = [[UIImageView alloc] init];
alertImage.hidden = YES;

But the image didn't disappear. What am I doing wrong?


Solution

  • The problem is that you are re-initializing alertImage, so it's not connected to the "original" one defined in IB anymore.

    Simply just use:

    alertImage.hidden = YES;