【问题标题】:Display images from documents directory显示文档目录中的图像
【发布时间】:2013-02-24 05:47:41
【问题描述】:

我正在使用以下方法在 AQGridview 中显示图像:

数据模型.m:

-(id)initWithCaption:(NSString*)theCaption andImage:(UIImage*)theImage andURLRequest:(NSURLRequest *)theURLRequest
{
    self = [super init];
    if(self)
    {
        self.caption = theCaption;
        self.image = theImage;
        self.myURLRequest = theURLRequest;
    }
    return self;
}

然后:

DataModel *appService = [[AppsDocumentService alloc] initWithCaption:theAppName andImage:[UIImage imageNamed:iconIdentifier] andURLRequest:requestObject];

其中iconIdentifier 是与应用支持文件夹中的图像匹配的字符串,例如@"Icon.png"

它只适用于存储在支持文件/Xcode 项目文件夹中的图像,我希望能够显示应用程序文档目录中的图像。

我尝试了一些变化:

iconIdentifier = @"/var/mobile/Applications/28CC364F-0895-4556-9F58-DAB5AB9104A7/Documents/downloads/AppIcons/Icon.png";

但这不起作用。

我希望有人能告诉我是否有办法修改我已经必须显示文档目录中的图像。

【问题讨论】:

    标签: ios objective-c nsdocumentdirectory aqgridview


    【解决方案1】:

    对不起各位——我一发布问题就想通了

    代替:

    initWithCaption:theAppName andImage:[UIImage imageNamed:iconIdentifier] andURLRequest:requestObject];
    

    我需要:

    initWithCaption:theAppName andImage:[UIImage imageWithData:[NSData dataWithContentsOfFile:iconIdentifier]] andURLRequest:requestObject];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-27
      • 2014-08-19
      • 1970-01-01
      • 2012-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多