Show images from documents directory in a image scroller

120 views Asked by At

Hey can anybody help me.. I have a complex problem . I have a set of images in the documents folder each with size of 350 - 500 kb. I am trying to display those images in a image scroller like the photoscroller of iPhone gallery. I am using UIPageViewController to view those images via sliding.

My Problem is about showing images. I tried to use SDWebImage framework (https://github.com/rs/SDWebImage) to display image asynchronously. But after 2 or more images displayed it shows memory warning and kills the app. I know how to retrieve data from file with Url of the file path.. But none of those methods are memory efficient. Methods like contentsOfUrl and imageWithContentsOfFile will rise the memory . So anyone suggest a goo way to do this. Thanks in advance.

1

There are 1 answers

1
Vishal Deshai On

For getting all images of same type use following method to find.

-[NSBundle pathForResource:ofType:inDirectory:]

For more

- (NSString *)applicationDocumentsDirectory {
return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];

}

-(void)loadimage{
NSString *workSpacePath=[[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"your image-name"];
UIImageView *myimage=[UIImageView alloc] initWithFrame:CGRectMake(0,0,20,20)];
myimage.image=[UIImage imageWithData:[NSData dataWithContentsOfFile:workSpacePath]];    
[self.view addSubView:myimage];
[myimage release];

}