码迷,mamicode.com
首页 > 其他好文 > 详细

QBImagePickerController 不可选择照片流中照片

时间:2015-11-27 17:07:32      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:

因为QBImagePickerController使用的ALAssetsLibrary方式来读取图片,如果采用默认方式去执行,那么根据url读取到的asset会为空,这时候我们就 需要特殊处理

 1  [self.assetsLibrary assetForURL:selectedAssetURL
 2                             resultBlock:^(ALAsset *asset) {
 3                                 // Add asset
 4 
 5                                 //普通照片方式
 6                                 if (asset) {
 7                                     [assets addObject:asset];
 8 //                                     Check if the loading finished
 9                                     if (assets.count == weakSelf.selectedAssetURLs.count) {
10                                         // Delegate
11                                         if (self.delegate && [self.delegate respondsToSelector:@selector(imagePickerController:didSelectAssets:)]) {
12                                             [self.delegate imagePickerController:self didSelectAssets:[assets copy]];
13                                         }
14                                     }
15                                 }
16                                 //照片流方式
17                                 else{
18                                     //照片流的处理方法
19                                     [self.assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupPhotoStream usingBlock:^(ALAssetsGroup *group, BOOL *stop)
20                                      {
21                                          [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
22                                              
23                                              if ([result.defaultRepresentation.url isEqual:selectedAssetURL]) {
24                                                  [assets addObject:result];
25                                                  *stop = YES;
26 //                                                  Check if the loading finished
27                                                  if (assets.count == weakSelf.selectedAssetURLs.count) {
28                                                      // Delegate
29                                                      if (self.delegate && [self.delegate respondsToSelector:@selector(imagePickerController:didSelectAssets:)]) {
30                                                          [self.delegate imagePickerController:self didSelectAssets:[assets copy]];
31                                                      }
32                                                  }
33                                              }
34                                          }];
35                                      } failureBlock:^(NSError *error) {
36                                          DDLogVerbose(@"Cann‘t found asset from stream:%@",[error localizedDescription]);
37                                      }];
38                                     
39                                 }
40                             } failureBlock:^(NSError *error) {
41                                 NSLog(@"Error: %@", [error localizedDescription]);
42                             }];

 

QBImagePickerController 不可选择照片流中照片

标签:

原文地址:http://www.cnblogs.com/ReBack2010/p/5000889.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!