2012-11-26 43 views
0

在我的應用程序中,我從url下載圖像並保存到應用程序文檔目錄中。現在我想將這些下載的圖像顯示爲圖像庫。對於我使用fGallery圖片庫,我可以配置它,併成功推動其導航控制器和fGallery觀點也是可見的,但它沒有顯示我的圖片,我提供fGalley與圖像陣列這樣需要關於以圖庫的形式下載圖像的幫助

頭文件

@interface myController <FGalleryViewControllerDelegate> 

@property (strong, nonatomic) FGalleryViewController *localGallery; 
@property (strong, nonatomic) NSMutableArray *localImages; 

類文件

//These are delegate methods of FGalleryViewControllerDelegate 
    - (NSString*)photoGallery:(FGalleryViewController*)gallery filePathForPhotoSize:(FGalleryPhotoSize)size atIndex:(NSUInteger)index 
    { 
     return [localImages objectAtIndex:index]; 
    } 

    - (NSString*)photoGallery:(FGalleryViewController *)gallery urlForPhotoSize:(FGalleryPhotoSize)size atIndex:(NSUInteger)index 
    { 
     return [localImages objectAtIndex:index]; 
    } 

    - (int)numberOfPhotosForPhotoGallery:(FGalleryViewController *)gallery 
    { 
     int num; 

     num = [localImages count]; 

     return num; 
    } 

    - (FGalleryPhotoSourceType)photoGallery:(FGalleryViewController *)gallery sourceTypeForPhotoAtIndex:(NSUInteger)index 
    {  
     return FGalleryPhotoSourceTypeLocal; 
    } 
    //Delegate method ends here 

// My method to show gallery with my images 
-(void)ShowGallery 
{ 
    localImages = [[NSMutableArray alloc]init];  

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDir = [paths objectAtIndex:0]; 
NSString *dataPath = [documentsDir stringByAppendingPathComponent:chatWithUser; 
NSString *msgsColumn; 

    //database query to fetch all images name and then 
    while([results next]) 
    { 
     msgsColumn = [results stringForColumn:@"msgs"]; 
     if([[[msgsColumn componentsSeparatedByString:@"."]objectAtIndex:1]isEqualToString:@"jpg"]) 
     { 
      [localImages addObject:[dataPath stringByAppendingPathComponent:msgsColumn]]; 
     } 
    } 

    [database close]; 

    localGallery = [[FGalleryViewController alloc]initWithPhotoSource:self]; 

    [self.navigationController pushViewController:localGallery animated:YES];  
} 

對於圖像路徑我用STR ingByAppendingPathComponent但我也試過stringByAppendingString指導圖像駐留在文檔目錄中,但沒有任何工作。

請幫助我弄清楚發生了什麼問題。

回答