我想保存2個圖像,因爲他們被挑選爲單獨的名稱。UIImagePickerController,以不同的名稱保存2個圖像到文檔目錄
我用這個指南,把我的UIImagePickerController:guide
基本上它是一個管理2個UIImageViews的,是有可能把它存2張不同的圖片,不同的名字一個的UIImagePickerController?或者我應該嘗試使uiimagepickercontroller不同?
這是我的代碼,它不適用於保存。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:@"latest_photo.png"];
//extracting image from the picker and saving it
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:@"public.image"]){
UIImage *editedImage = [info objectForKey:UIImagePickerControllerEditedImage];
NSData *webData = UIImagePNGRepresentation(editedImage);
[webData writeToFile:imagePath atomically:YES];
}
switch (_selectedPhotoType) {
case imageView1Type:
imageView1.image = [info objectForKey:UIImagePickerControllerOriginalImage];
break;
case imageView2Type:
imageView2.image = [info objectForKey:UIImagePickerControllerOriginalImage];
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:^{ }];
}
,所以你想在同一攝取的圖像保存到2個不同的文件嗎? – heximal
簡單的問題你想要一個按鈕有兩個選擇器或兩個按鈕與一個選擇器..... – Spynet
@heximal不,我有2個uiimageviews,當我點擊每個按鈕下,我選擇2個不同的圖像...我想將它們保存在每個根據名稱 – KennyVB