【问题标题】:How to display images on a table view that are saved in the document directory如何在表格视图上显示保存在文档目录中的图像
【发布时间】:2013-10-06 03:00:21
【问题描述】:

我目前正在使用 UIImagePickerController 允许用户拍照,然后将其缩放为 600x800 JPEG 并将其保存为 4 种不同的质量(25%、50%、75% 和 100%)。我试图找到一种方法,可以从文档目录中获取这些图像并将它们作为缩略图显示在表格视图中,然后用户可以单击缩略图来放大图像。

任何帮助或信息将不胜感激。

谢谢!

【问题讨论】:

标签: iphone ios uiimage save


【解决方案1】:
    NSString *path=[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"image"];
    UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(0,0,40,40)];
    imgView.image=[UIImage imageWithData:[NSData dataWithContentsOfFile:path]];
    [self.view addSubview:imgView];

【讨论】:

  • 我会在哪里调用这个方法?它会在 cellForRowAtIndexPath 内吗?抱歉,我是 iOS 新手,我不能 100% 确定。
  • 嗯好的,我需要在我的 .h 文件中为 addSubView 创建一个属性?
  • @Fernando- 如果你在 tableview 上添加然后使用 [cell.contentview addsubview:imgView];
  • 如我所见:UIView 没有可见的@interface 声明选择器“addSubView”错误
  • [cell.contentView addSubview:imgView];
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-03
  • 2014-08-19
  • 2017-05-19
  • 2013-02-24
  • 2011-11-01
  • 1970-01-01
相关资源
最近更新 更多