gpt4 book ai didi

ios - 将相册中的图像分配给变量 Objective-c

转载 作者:行者123 更新时间:2023-11-29 02:15:28 28 4
gpt4 key购买 nike

我正在使用以下代码从相册中获取图像:

-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;

picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

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

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];}

谁能帮我把这张图片赋值给一个变量?我想稍后使用 stackblur 对其进行模糊处理:

UIImage *newIma=[oldIma stackBlur:radius];

提前致谢!

最佳答案

在获取用户选择的图像时设置 UIImage

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil];
// Create the UIImage in your @implementation and set it here
myImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
myImageView.image = myImage;
}

关于ios - 将相册中的图像分配给变量 Objective-c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28801150/

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