本文转载至:http://blog.csdn.net/longzs/article/details/8373586
从 iphone 的 照片库中选取的图片,由于 系统不能返回其文件的具体路径,所以这时要用到 ALAssetsLibrary
代码如下:
ALAssetsLibrary* alLibrary = [[ALAssetsLibrary alloc] init];
__block float fileMB = 0.0;
[alLibrary assetForURL:[info objectForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset)
{
ALAssetRepresentation *representation = [asset defaultRepresentation];
fileMB = (float)([representation size]/perMBBytes);
NSLog(@"size of asset in bytes: %0.2f", fileMB);
iHasAsset = 1;
[alLibrary release];
}
failureBlock:^(NSError *error)
{
iHasAsset = 2;
[alLibrary release];
}];