论坛首页 移动开发技术论坛

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

浏览 3619 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-03-24   最后修改:2011-03-24
iOS

 

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

}

论坛首页 移动开发技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics