我正在使用scrollview进行图片加载。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
dataPath = [documentsDirectory stringByAppendingPathComponent:@"/Images"];
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error];
NSArray *docsArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:dataPath error:&error];
for (int i = 0; i < [docsArray count]; i++)
{
NSString *strPath = [docsArray objectAtIndex:i];
if([strPath containsString:[NSString stringWithFormat:@"%@_",strID]])
{
[imgArray addObject:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@",dataPath,strPath]]];
NSLog(@"%@%@",dataPath,strPath);
}
}
if([imgArray count]>0)
[self showImages];