gpt4 book ai didi

ios - UIImagePickerController没有将图像分配给uiimageview

转载 作者:行者123 更新时间:2023-12-01 16:49:33 25 4
gpt4 key购买 nike

我正在尝试使用UIImagePickerController并将图像保存到UIImageView,但是图像没有保存?

- (IBAction)handleAvatarTap:(id)sender {
DLog(@"");

UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

[picker dismissModalViewControllerAnimated:YES];
UIImage* original =[info objectForKey:@"UIImagePickerControllerOriginalImage"];

// This is the line that sets the image but the original image assigned to it is still there?
[self.avatarImage setImage:[UIImage imageWithCGImage:original.CGImage]];


}

最佳答案

您确定avatarImage是init吗?

就像是:

self.avatarImage = [[[UIImageView alloc] initWithFrame:myFrame] autorelease];
self.avatarImage.image = original;

关于ios - UIImagePickerController没有将图像分配给uiimageview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17151396/

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