I'm using the following method to display images in an 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;
}
Then:
DataModel *appService = [[AppsDocumentService alloc] initWithCaption:theAppName andImage:[UIImage imageNamed:iconIdentifier] andURLRequest:requestObject];
Where iconIdentifier
is a string matching an image in the app's Supporting files folder, e.g. @"Icon.png"
It works but only with images stored in Supporting files / Xcode project folder and I'd like to be able to display images from the app's documents directory.
I tried some variations along the lines of:
iconIdentifier = @"/var/mobile/Applications/28CC364F-0895-4556-9F58-DAB5AB9104A7/Documents/downloads/AppIcons/Icon.png";
but that isn't working.
I was hoping someone could tell me if there's a way to modify what I already have to display images from the documents directory.
Sorry folks - figured it out almost as soon as I posted the question
Instead of:
initWithCaption:theAppName andImage:[UIImage imageNamed:iconIdentifier] andURLRequest:requestObject];
I needed:
initWithCaption:theAppName andImage:[UIImage imageWithData:[NSData dataWithContentsOfFile:iconIdentifier]] andURLRequest:requestObject];