我是 i Phone 编程的新手。在这段代码中,我将图像存储在数组中,这些图像是我在捆绑中添加的,我可以在缩略图中显示该图像。同样,我在文档目录中创建了私人文件夹,我添加了 2 张图像之后,我检索数组中的图像,但我无法在缩略图中显示私有文档目录图像,但我可以显示捆绑图像。在下面的代码 2 localImages 中是否有一个 localImages 我有存储捆绑图像和另一个 localImages我已经存储了私有文档目录文件夹图像。现在正在显示捆绑图像,但我评论说捆绑 localImages。并且我在相同的 localImages 中使用私有文档目录图像,它无法显示一些预期。
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"Tauky"];
NSLog(@"%@",savedImagePath);
NSError *error = nil;
if (![[NSFileManager defaultManager] fileExistsAtPath:savedImagePath])
[[NSFileManager defaultManager] createDirectoryAtPath:savedImagePath withIntermediateDirectories:NO attributes:nil error:&error];
dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:savedImagePath error:&error];
localImages = [[NSArray alloc] init];
predicate = [NSPredicate predicateWithFormat:@"self ENDSWITH '.jpeg'"];
imagesOnly = [dirContents filteredArrayUsingPredicate:predicate];
localImages = [NSArray arrayWithArray:imagesOnly];
NSLog(@"%@",localImages);
self.title = @"FGallery";
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
localCaptions = [[NSArray alloc] initWithObjects:@"images53", @"image57",nil];
//localImages =[[NSArray alloc] initWithObjects: @"lava.jpeg",@"hawaii.jpeg",nil];
NSLog(@"%@",localImagess);
期望在代码下方
- (void)reloadGallery
{
_currentIndex = _startingIndex;
_isThumbViewShowing = NO;
// remove the old
[self destroyViews];
// build the new
if ([_photoSource numberOfPhotosForPhotoGallery:self] > 0) {
// create the image views for each photo
[self buildViews];
// create the thumbnail views
[self buildThumbsViewPhotos];
// start loading thumbs
[self preloadThumbnailImages];
// start on first image
[self gotoImageByIndex:_currentIndex animated:NO];
// layout
[self layoutViews];
}
}
在控制台中它的显示是这样的
self=(FGalleryViewController *)0x6877050
_cmd=(SEL)0x103cf reloadgallery
我没有得到我尝试了很多方法。请帮助我谢谢