因为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 }];