簡體   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