ios-获取系统相簿里边的所有照片
#import <AssetsLibrary/AssetsLibrary.h>
-(void)getImgs{
dispatch_async(dispatch_get_main_queue(), ^{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror){
NSLog(@"相册访问失败 =%@", [myerror localizedDescription]);
if ([myerror.localizedDescription rangeOfString:@"Global denied access"].location!=NSNotFound) {
NSLog(@"无法访问相册.请在'设置->定位服务'设置为打开状态.");
}else{
NSLog(@"相册访问失败.");
}
};
ALAssetsGroupEnumerationResultsBlock groupEnumerAtion = ^(ALAsset *result, NSUInteger index, BOOL *stop){
if (result!=NULL) {
if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]) {
NSString *urlstr=[NSString stringWithFormat:@"%@",result.defaultRepresentation.url];//图片的url
/*result.defaultRepresentation.fullScreenImage//图片的大图
result.thumbnail //图片的缩略图小图
// NSRange range1=[urlstr rangeOfString:@"id="];
// NSString *resultName=[urlstr substringFromIndex:range1.location+3];
// resultName=[resultName stringByReplacingOccurrencesOfString:@"&ext=" withString:@"."];//格式demo:123456.png
*/
[self._dataArray addObject:urlstr];
}
}
};
ALAssetsLibraryGroupsEnumerationResultsBlock
libraryGroupsEnumeration = ^(ALAssetsGroup* group, BOOL* stop){
if (group == nil)
&n
相关新闻>>
- 发表评论
-
- 最新评论 更多>>