---
title: "iPhone快速参考：显示本地的图片"
author: "tiger888"
date: "2011-03-24T22:50:45Z"
tags: []
categories: ["移动开发"]
slug: "iphone"
draft: false
lastmod: "2011-03-24T22:51:35Z"
id: 974677
url: "https://tiger888.iteye.com/blog/974677"
---

\- (void)viewDidLoad

{

    NSString \*homeDirectoryPath = NSHomeDirectory();

    NSString \*imagePath = \[homeDirectoryPath stringByAppendingString:@"/graph.png"];

    NSLog(@"Image: %@", imagePath);

    if (!\[\[NSFileManager defaultManager] fileExistsAtPath:imagePath isDirectory:NULL]) 

    {

        UIImageView * myImageView = \[\[UIImage alloc] initWithContentsOfFile: imagePath];

        //\[\[NSFileManager defaultManager] createDirectoryAtPath:imagePath attributes:nil];

 

        \[self.view addSubview:myImageView];

        \[myImageView release];

    }    

    \[super viewDidLoad];

}