【发布时间】:2015-04-14 06:48:25
【问题描述】:
我想到了一个让我发疯的问题。我已经搜索了很多来解决它,但是我找到的所有答案都是旧的并且没有帮助。
我目前正在开发使用 UIImagePickerControllerDelegate 和 didFinishPickingMediaWithInfo 的应用程序,我想将所选图像保存到应用程序文件夹。
到目前为止,我可以用这个选择图像;
- (IBAction)btnPressed:(UIButton *)sender
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imgPicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
imgPicker.allowsEditing = NO;
[self presentViewController:imgPicker animated:YES completion:nil];
}
}
但无法使用 didFinishPickingMediaWithInfo 将其保存到应用程序;
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:YES completion:nil];
if ([mediaType isEqualToString:(NSString *) kUTTypeImage])
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
//Assigning the selected image to imageView to see on UI side.
imageViewerImage.image = image;
}
}
我想知道这一点之后的部分应该是什么。
感谢您提供的任何帮助。
【问题讨论】:
-
所以问题是如何将 UIImage 写入文件夹中的文件。
-
是的@gabbler 这正是我要找的。span>
-
你没有搜索很多来解决它,否则你会找到它,因为它是“将图像保存到 ios 中的文档文件夹”的第一个搜索结果 - stackoverflow.com/questions/2037432/…。
标签: ios objective-c iphone ios8 uiimagepickercontroller