我使用的方法writeImageToSavedPhotosAlbum:元數據:completionBlock:拍攝照片保存到相冊,代碼爲:writeImageToSavedPhotosAlbum:元數據:completionBlock:
-(void)savePhotoToAlbum{
CGImageRef imageRef=[imageView image].CGImage;
NSDictionary *currentDic=[self getLocation];
NSDictionary *metadata=[NSDictionary dictionaryWithDictionary:currentDic];
ALAssetsLibrary *library=[[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:imageRef metadata:metadata completionBlock:^(NSURL *assetURL,NSError *error){
if(error == nil)
{
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:nil message:@"Save success!" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
else
{
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:nil message:@"Save failure!" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}];
[library release];
} 。該方法的getLocation是獲取用戶當前位置的那個!可以保存成功!然後我想從相冊中選取使用UIImagePickerController拍攝的圖片!代碼是:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{ if([picker sourceType]==UIImagePickerControllerSourceTypeSavedPhotosAlbum)//picker image delegate
{
NSString *mediaType=[info objectForKey:UIImagePickerControllerMediaType];
if([mediaType isEqualToString:@"public.image"])
{
NSDictionary *metadata=[info objectForKey:UIImagePickerControllerMediaMetadata];
NSLog(@"%@",metadata);
}
}
}
然後記錄元數據爲空。這是爲什麼?我如何獲取我保存的元數據信息?謝謝!
實話告訴你,我知道,可作爲sourceType的圖像的元數據UIImagePickerControllerSourceTypeCamera.But我不知道如何獲得元數據信息?哪種方法可以使用? – scofield