gpt4 book ai didi

iphone - segue通过后图片将不会显示

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

如标题所述,我试图在UIImageview中显示UIImage,问题是它不会显示。在我展示它之前,我从另一个角度通过了segue。当我断点时,我看到分配了UIImage但没有图片显示,我尝试将其设置为静态图片,并且效果很好。

相关代码应为...

在FirstViewController.m中

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

UIImage* img = [info objectForKey:UIImagePickerControllerOriginalImage];

if (picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
NSLog(@"Bild hämtad!");
[self moveImage];
}
else
{
UIImageWriteToSavedPhotosAlbum(img, self, @selector(image:didFinishSavingWithError:contextInfo:), Nil);
}

[picker dismissModalViewControllerAnimated:YES];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
}

- (void)image: (UIImage *)image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo{

if (!error) {
NSLog(@"Bild sparad!");
[self moveImage];
}
else{
NSLog(@"%@",error);
}
}
-(void)moveImage
{
[self performSegueWithIdentifier:@"ImageEdit" sender:self];
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSLog(@"Bild Flyttad!");

}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:self
{
if ([[segue identifier] isEqualToString:@"ImageEdit"])
{
[segue.destinationViewController setMImage:image];
}

}

在ImageEditController.m中
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[imageView setImage:_mImage];
NSLog(@"Bild Visas!");
}

我知道有很多代码,但是我认为发布多于少总比更好。

最佳答案

您是否曾经初始化过imageView?

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
imageView = [[UIImageView alloc] init];
[imageView setImage:_mImage];
NSLog(@"Bild Visas!");
}

如果从未初始化过该函数,则对其进行的任何函数调用都只会静默失败(在nil指针上调用一个函数不会执行任何操作)。

关于iphone - segue通过后图片将不会显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10690645/

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