在我的应用程序中,我从 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];
}
对于图像路径,我使用了 stringByAppendingPathComponent但我也尝试了 stringByAppendingString来指导图像驻留在文档目录中,但没有任何效果。
请帮助我找出问题所在。