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
相关新闻>>
- 发表评论
-
- 最新评论 更多>>
今日头条
更多>>您可能感兴趣的文章
- iPhone开发学习笔记006—— NSNotification自定义通知名
- Lexical or Preprocessor Issue 'xxx.h
- ios学习笔记(二)xcode 4.3.2下实现基本交互
- ios开发问题:添加库和复制其它工程文件编译错误问题
- iphone开发之object c基础一定义接口
- Memory on the iPhone
- Android:实现TabWidget选项卡按钮在屏幕下方
- (iPhone/iPad开发)presentViewController相应方法在SDK5.0前后
- iPhone应用开发之十一:常用的三种动画表现效果
- 多线程之NSInvocationOperation