读书人

iPhone高速参考:显示本地的图片

发布时间: 2012-09-22 21:54:54 作者: rapoo

iPhone快速参考:显示本地的图片

?

- (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];

}

读书人网 >Iphone

热点推荐