NSString *mainDir=[NSString stringWithFormat:@"/var/mobile/Media/Photos/Thumbs"]; //所有照片都存在该路径下
NSArray *childrenFilenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:mainDir error:nil];
float i=0.0,j=0.0;
for(NSString *fn in childrenFilenames) {
NSString *tempStr=[mainDir stringByAppendingPathComponent:fn];
NSDictionary *attributes = [[NSFileManager defaultManager] fileAttributesAtPath:tempStr traverseLink:NO];
BOOL isDirectory=[[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeDirectory];
if (isDirectory) {
NSArray *imageFile = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:tempStr error:nil];
NSString *imagePath=[tempStr stringByAppendingPathComponent:[imageFile objectAtIndex:0]];
NSLog(@"the image filedirectory is %@",imagePath);
UIImage *img=[UIImage imageWithContentsOfFile:imagePath];
UIImageView *imgView=[[UIImageView alloc] initWithImage:img];
[imgView setFrame:CGRectMake(i, j, 150, 150)];
[self.view addSubview:imgView];
[imgView release];
i+=100.0;
j+=100.0;
}
}
读取Photos全部图标的方法(转)
最新推荐文章于 2024-07-26 13:58:16 发布