How to get new image, changing the image name no effect, still reading the old image
In 开发者_如何学Cmy universal app I have some images in Resources folder by the convention "image.png" "image@2x.png" etc.
When I change names of the images in the Resources folder I can see different images in the Simulator, But in real device whatever I do it keeps reading the previous image files. is there a cache mechanism or something do I need to clean or refresh about image files in Xcode3? Or I shouldn't change image names in res folder?
This is how I read:
+(UIImage *) APP_CRYSTAL_SELECTION{
NSString *path = [[NSBundle mainBundle] pathForResource:@"cry" ofType:@"png"];
return [UIImage imageWithContentsOfResolutionIndependentFile:path];
}
Yes, caching might be at play here. To repopulate any imageView
I always pass my imageView through a setup method -
- (UIImageView *)setupImageView:(UIImageView *)imgView flags:(UIViewContentMode) mode
{
[imgView setImage:nil];
[imgView setImage:[UIImage imageNamed:@"1pixel.gif"]];
if(mode)
[imgView setContentMode:mode];
else if(mode == 0)
nil; //no flags
return imgView;
}
Basically I reset the view with a simple 1pixel Image, now it's ready to be repopulated with any new image. hope this helps...
If you are using [UIImage imageNamed:], it's loading the image from the cache and you should delete it! Read here: http://developer.apple.com/library/ios/documentation/uikit/reference/UIImage_Class/Reference/Reference.html#//apple_ref/occ/clm/UIImage/imageNamed:
Try deleting your app from simulator or clean all targets.
精彩评论