首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 平面设计 > 图形图像 >

imagePickerController 获取图片的照相时间等信息

2014-01-03 
imagePickerController 获取图片的拍照时间等信息//当我们选中图片的时候进入的代理//其实这里图片,照相机

imagePickerController 获取图片的拍照时间等信息

//当我们选中图片的时候进入的代理//其实这里图片,照相机共用一个代理

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

?

? ? UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];

? ? UIButton *tempButton = (UIButton *)[self.view viewWithTag:flagImageButton];

? ? [tempButton setBackgroundImage:image forState:UIControlStateNormal];

? ? NSLog(@"info == %@",info);

?? ?

? ? NSData *tempImageData = UIImageJPEGRepresentation(image, 0.5);

? ? [self.imageDataArray addObject:image];

?? ?

? ? if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {

?? ? ? ?

?? ? ? ?

? ? ? ? // Recover the snapped image

? ? ? ? UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

?? ? ? ?

? ? ? ? //元数据

? ? ? ? NSDictionary *dict = [info objectForKey:UIImagePickerControllerMediaMetadata];

? ? ? ? NSMutableDictionary *metadata=[NSMutableDictionarydictionaryWithDictionary:dict];

? ? ? ? //EXIF数据

? ? ? ? NSMutableDictionary *EXIFDictionary =[[metadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy];

?? ? ? ?

? ? ? ? NSLog(@"EXIFDictionary==%@",EXIFDictionary);

?? ? ? ?

?? ? ? ?

? ? ? ? NSLog(@"DateTimeDigitized哈哈哈哈==%@",[EXIFDictionary objectForKey:@"DateTimeDigitized"]);

? ? ? ? NSString *tempTimeChuo = [ViewControllerFactory fromTimeToChui:[EXIFDictionary objectForKey:@"DateTimeDigitized"]];

? ? ? ? [self.timeChuoArray addObject:tempTimeChuo];

?? ? ? ?

? ? ? ? // Save the image to the album

? ? ? ? //UIImageWriteToSavedPhotosAlbum(image, self, @selector(imagedidFinishSavingWithError:contextInfo:), nil);

? ? ? ? UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

?? ? ? ?

? ? ? ? NSLog(@"拍照的");

?? ? ? ?

? ? ? ? [selfdismissViewControllerAnimated:YEScompletion:nil];

?? ?

?? ? ? ?

? ? }

? ? elseif (picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary)

? ? {

?? ? ? ?

?? ? ? ?

? ? ? ? NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];

? ? ? ? ALAssetsLibrary *library = [[ALAssetsLibraryalloc] init];

? ? ? ? [library assetForURL:assetURL

?? ? ? ? ? ? ? ? resultBlock:^(ALAsset *asset) {

? ? ? ? ? ? ? ? ? ? ?

?? ? ? ? ? ? ? ? ? ? NSLog(@"asset===%@",asset);

?? ? ? ? ? ? ? ? ? ? //查看资源的创建时间

?? ? ? ? ? ? ? ? ? ? NSLog(@"ALAssetPropertyDate:%@",[asset valueForProperty:ALAssetPropertyDate]);

?? ? ? ? ? ? ? ? ? ? NSString *tempTimeChuo = [ViewControllerFactory fromTimeToChui:[asset valueForProperty:ALAssetPropertyDate]];

?? ? ? ? ? ? ? ? ? ? [self.timeChuoArray addObject:tempTimeChuo];

? ? ? ? ? ? ? ? ? ? ?

?? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? failureBlock:^(NSError *error) {

? ? ? ? ? ? ? ? }];

?? ? ? ?

? ? ? ? [picker dismissViewControllerAnimated:YEScompletion:^{

?? ? ? ? ? ?

? ? ? ? }];

?? ? ? ?

? ? }

?

?? ?

?? ?

?

}

热点排行