- (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];
}
加载图片示例
本文介绍了一个简单的Objective-C方法,用于检查指定路径下是否存在名为“graph.png”的图片文件。如果该文件不存在,则尝试从该路径加载图片并将其显示在一个UIImageView中。
2187

被折叠的 条评论
为什么被折叠?



