[英]Display images from documents directory
我正在使用以下方法在AQGridview中显示图像:
DataModel.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"
文件夹中的图像匹配的字符串,例如@"Icon.png"
它可以使用,但仅适用于存储在Supporting files / Xcode项目文件夹中的图像,我希望能够显示该应用程序的文档目录中的图像。
我尝试了以下几种方法:
iconIdentifier = @"/var/mobile/Applications/28CC364F-0895-4556-9F58-DAB5AB9104A7/Documents/downloads/AppIcons/Icon.png";
但这不起作用。
我希望有人能告诉我是否有一种方法可以修改我已经必须要显示的文档目录中的图像。
抱歉,人们-在我发布问题后几乎就知道了
代替:
initWithCaption:theAppName andImage:[UIImage imageNamed:iconIdentifier] andURLRequest:requestObject];
我需要:
initWithCaption:theAppName andImage:[UIImage imageWithData:[NSData dataWithContentsOfFile:iconIdentifier]] andURLRequest:requestObject];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.