UIImageView doesn't update with my image
I am trying to set my image:
detailedEventViewController.thumbnail.image = [UIImage imageNamed:@"amnesia.png"];
But the imageview appears blank. amnesia.png i开发者_运维技巧s in my resources group. The file exists.
Results of my log:
2011-01-08 10:52:32.822 HD Pocket Vacations[25271:207] Image: <UIImage: 0x66203b0>
2011-01-08 10:52:32.823 HD Pocket Vacations[25271:207] dEVC: <DetailedEventViewController: 0x6628340>
2011-01-08 10:52:32.824 HD Pocket Vacations[25271:207] thumbnail: (null)
Did you link up the thumbnail
property to a UIImageView
in IB?
Try to get a little more information by changing the line to:
UIImage *img = [UIImage imageNamed:@"amnesia.png"];
NSLog(@"Image: %@",img);
NSLog(@"dEVC: %@",detailedEventViewController);
NSLog(@"thumbnail: %@",detailedEventViewController.thumbnail);
detailedEventViewController.thumbnail.image = img;
and tell what you see in the debugger console window.
Following on from the logs you provided. When are you attempting to set this? If you are trying to do this in your init method it won't have bound to the Nib yet and why it is Null.
Do this in the viewDidLoad:
method and it should have hooked up.
精彩评论