tags:

views:

85

answers:

2

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.

A: 

Try replacing self.coverImage with just coverImage:
self.coverImage will invoke a different setter to just coverImage.

Hope this helps and the problem is resolved,
jrtc27

jrtc27
The self.coverImage basically means getCoverImage, and makes no difference. I just put it in my code for clarity. But just to make sure I wasn't missing something, I tried it anyway and it still didn't work. Thanks
just_another_coder
A: 

Is there a chance that your ViewController is being released?

Kenny
No the VC continues to run fine in the app. There are other things happening, but not in relation to the image. I did the NSLog as shown above and it's not nil, so I'm fairly certain the image and VC aren't released.
just_another_coder
Remember that just because they are not nil does not necessarily mean they have not been released. I am trying to recreate your problem right now. Will get back if I have any luck.
Kenny
See my comment above. Thank for your help.
just_another_coder