gpt4 book ai didi

ios - imagePickerController设置UIImageView.image不改变图片显示

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:07:06 29 4
gpt4 key购买 nike

我试图将 UIImageView 的图像设置为下面 UIImagePickerController 的返回值。我的UIImageView profileImageView是在viewdidload中实例化的。奇怪的是,UIImagePickerController返回的图片并没有在profileImageView中显示出来。一开始我以为是图片问题,所以我把它修复为SR-rewards.jpg。添加NSLog,显示[profileImageView setImage:[UIImage imageNamed:@"SR-rewards.jpg"]]已经执行,但是profileImageView.image.size.height为0。然后我使用 再拍一次
[profileImageView performSelectorOnMainThread:@selector(setImage:) withObject: [UIImage imageNamed:@"SR-rewards.jpg"] waitUntilDone:YES];
在主线程中运行它。尽管如此,图像仍然没有显示,profileImageView.image.size.height 变为 277。

知道原因吗?我该如何设置图像?

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

UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
[profileImageView setImage:[UIImage imageNamed:@"SR-rewards.jpg"]];//[self cropImage:smallImage];
NSLog(@"%f" , profileImageView.image.size.height);
[picker dismissViewControllerAnimated:YES completion:NULL];

}

问候锤子

最佳答案

更新主队列中的 UI。

dispatch_async(dispatch_get_main_queue(), ^{
[profileImageView setImage:[UIImage imageNamed:@"SR-rewards.jpg"]];
});

关于ios - imagePickerController设置UIImageView.image不改变图片显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26470464/

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