gpt4 book ai didi

ios - 拍摄照片并将其保存到相机胶卷

转载 作者:可可西里 更新时间:2023-11-01 06:20:42 31 4
gpt4 key购买 nike

我遇到了一个问题,我只想要一个简单的解决方案来拍照,然后将其保存在我的应用程序中。然而到目前为止,我所能做的就是拍摄照片并将其加载到 UIImageView 中,但它不会保存在相机胶卷中。

- (IBAction)takePhoto:(UIButton *)sender 
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

[self presentViewController:picker animated:YES completion:NULL];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;

[picker dismissViewControllerAnimated:YES completion:NULL];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissViewControllerAnimated:YES completion:NULL];
}

如有任何帮助,我们将不胜感激。相信我,我真的需要它。

最佳答案

你会想要这样做:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];

self.imageView.image = chosenImage;

UIImageWriteToSavedPhotosAlbum(chosenImage, nil, nil, nil);

[picker dismissViewControllerAnimated:YES completion:NULL];
}

关于ios - 拍摄照片并将其保存到相机胶卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24745713/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com