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.
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];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.