I have the following code in place:
- (void)viewDidLoad {
NSString *homeDirectoryPath = NSHomeDirectory();
NSString *imagePath = [homeDirectoryPath stringByAppendingString:@"/graph.png"];
NSLog(@"Image: %@", imagePath);
if (![[NSFileManager defaultManager] fileExistsAtPath:imagePath isDirectory:NULL])
{
graph = imagePath;
//[[NSFileManager defaultManager] createDirectoryAtPath:imagePath attributes:nil];
}
'graph' is defined as UIImageView. I'm trying to display the file in the path 'imagePath'. I know the code graph = imagePath is not correct, 开发者_StackOverflow社区as the variable 'imagePath' states it contains the path to the image.
How would I display my image located at the specific image path ?
Regards, Stephen
You'll have to create an imageview object, set it as the image view's image and release the image you created:
UIImage *graphImage = [[UIImage alloc] initWithContentsOfFile: imagePath];
graph.image = graphImage;
[graphImage release];
精彩评论