So, I’m currently saving images in my UIImageView via this method:
- (void)applicationDidEnterBackground:(UIApplication*)application {
NSString *image1 = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image1.png"];
NSString *image2 = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image2.png"];
}
The images save just fine, but I have no idea how to set the UIImageViews images in viewDidLoad. This is what I’ve been trying:
- (void)viewDidLoad
{
self.imageView.image =[UIImage imageNamed:[(NSHomeDirectory *)Documents objectForKey:@"image1"]];
self.imageView2.image =[UIImage imageNamed:[(NSHomeDirectory *)Documents objectForKey:@"image1"]];
}
But, obviously that is not working. I’m having trouble understanding the basics here. Any help would be great, thanks!
The
-imageNamed:method looks in the application’s main bundle if the named image hasn’t been cached yet. From the docs:(See UIImage class reference)
You want
-imageWithContentsOfFile:instead.