I'm using the HSImageSidebarView
and in the example included in the open source project, this is how to load the images in the sidebar :
-(UIImage *)sidebar:(HSImageSidebarView *)sidebar imageForIndex:(NSUInteger)anIndex {
int color = [[colors objectAtIndex:anIndex] intValue];
switch (color % 3) {
case 0:
return [UIImage imageNamed:@"Blue"];
break;
case 1:
return [UIImage imageNamed:@"Red"];
break;
default:
return [UIImage imageNamed:@"Green"];
}
}
What my problem is how to add my own images from the NSDocumentDirectory
. Here is my array :
self.images = [NSMutableArray new];
for(int i = 0; i <= 100; i++)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"Images%d.png", i]];
NSLog(@"savedImagePath=%@",savedImagePath);
if([[NSFileManager defaultManager] fileExistsAtPath:savedImagePath]){
[images addObject:[UIImage imageWithContentsOfFile:savedImagePath]];
NSLog(@"file exists");
}
NSLog(@"file does not exist");
}
Thanks for the help!