Very very weird problem with UIImageView property - I can access it then I can't, and it's not nil.

Posted by just_another_coder on Stack Overflow See other posts from Stack Overflow or by just_another_coder
Published on 2010-05-29T10:51:14Z Indexed on 2010/05/29 10:52 UTC
Read the original article Hit count: 247

Filed under:
|

Very very weird problem with UIImageView property on iPad application

@interface MyViewController : UIViewController {
    IBOutlet UIImageView* coverImage;
}
@property(nonatomic, retain) IBOutlet UIImageView* coverImage;

… more code

@implementation MyViewController

@synthesize coverImage;

… more code

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString* imageName = @"my_image.png";
    UIImage* tempImage = [UIImage imageNamed:imageName];
    [self.coverImage setImage:tempImage];
}

The above code WILL display the image.

In another part of code:

-(IBAction) stopButtonPressed:(id)sender {
    [self.coverImage setHidden:YES];
    NSLog(@"coverImage desc: %@", [coverImage description]);
}

The image will NOT disappear. I know the reference to the image isn't nil, because it gives me this output:

2010-05-29 17:37:40.706 MyApp[95360:207] coverImage desc: UIImageView: 0x5128420; frame = (0 0; 1024 768); autoresize = RM+BM; userInteractionEnabled = NO; layer = CALayer: 0x512bed0

In addition, if I move the code in viewDidLoad to another part of the class, and try to execute it from there, it fails to show the image at all.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ipad