码迷,mamicode.com
首页 > 移动开发 > 详细

ios 判断相册文件图片大小的方法

时间:2015-01-12 15:54:05      阅读:1342      评论:0      收藏:0      [点我收藏+]

标签:

获取ios相册图片文件大小,
很多人,想到的就是取到文件图片的位置,然后通过NSdata来获取图片大小,殊不知,这样获取到的图片大小并非准确。

正确的方法应是在代理中实现

ALAssetsLibrary* alLibrary = [[ALAssetsLibrary alloc] init];

    [alLibrary assetForURL:[info objectForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset)

     {

         ALAssetRepresentation *representation = [asset defaultRepresentation];

         if ([representation size] > 1024*1024*2) {

             UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"图片超出了2M,请重新选择" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];

             [alert show];

             [alert release];

             

             [self setretakeButtonEnable:picker];

             

             [alLibrary release];

             

             return;

         }

}

ios 判断相册文件图片大小的方法

标签:

原文地址:http://www.cnblogs.com/uwking/p/4218362.html

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