2013-03-08 20 views
0

我使用下面的方法在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

對不起鄉親 - 幾乎就想通了,因爲我張貼的問題

相反的:

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

我需要:

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