繁体   English   中英

在图像滚动器中显示来自文档目录的图像

[英]Show images from documents directory in a image scroller

嘿,有人可以帮我吗。我有一个复杂的问题。 我在documents文件夹中有一组图像,每个图像的大小为350-500 kb。 我试图在像iPhone画廊的photocroller的图像滚动器中显示那些图像。 我正在使用UIPageViewController通过滑动查看那些图像。

我的问题是关于显示图像。 我试图使用SDWebImage框架( https://github.com/rs/SDWebImage )异步显示图像。 但是在显示2张或更多图片后,它会显示内存警告并杀死该应用程序。 我知道如何使用文件路径的Url从文件中检索数据。但是这些方法都不是内存有效的。 诸如contentsOfUrl和imageWithContentsOfFile之类的方法将增加内存。 因此,任何人都建议采取一种行之有效的方法。 提前致谢。

要获取所有相同类型的图像,请使用以下方法查找。

-[NSBundle pathForResource:ofType:inDirectory:]

欲了解更多

- (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];

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM