我正在使用以下方法在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"
它的工作原理只适用于存储在支持文件/ Xcode项目文件夹中的图像,我希望能够从应用程序的文档目录中显示图像。
我尝试了一些变化:
iconIdentifier = @"/var/mobile/Applications/28CC364F-0895-4556-9F58-DAB5AB9104A7/Documents/downloads/AppIcons/Icon.png";
但这不起作用。
我希望有人能告诉我是否有办法修改我已经拥有的文件目录中的图像。
答案 0 :(得分:0)
对不起朋友 - 几乎在我发布问题后就知道了
而不是:
initWithCaption:theAppName andImage:[UIImage imageNamed:iconIdentifier] andURLRequest:requestObject];
我需要:
initWithCaption:theAppName andImage:[UIImage imageWithData:[NSData dataWithContentsOfFile:iconIdentifier]] andURLRequest:requestObject];