gpt4 book ai didi

ios - UIImage 和 prepareforSegue 无法传递图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:02:52 25 4
gpt4 key购买 nike

这里是我的代码:

@property (weak, nonatomic) IBOutlet UIImageView *chosedImage;

- (IBAction)cropImageTap:(id)sender {

[self dismissViewControllerAnimated:YES completion:^{
UIImage * pickedImage = self->_chosedImage;
//[UIImage imageNamed:@"helloWorld.jpg"];

[self performSegueWithIdentifier:@"gotomainimage" sender:pickedImage];

}];
}

我的表演转场如下:

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{


PostVC *vc = (PostVC*)segue.destinationViewController;
UIImage *img = (UIImage*)sender;

if (img.images == nil) {
NSLog(@"null img");
vc.Sourcemage = img;
}
else {

NSLog(@"not null img");
vc.Sourcemage = img;
}

}

我只得到空图像。我的图像没有出现。我在这里做的问题是什么?

请帮帮我

更新:

我更新后的代码,工作方式如下 - 给我的控制台消息如下:

它的空数据a - post vc 它不是空图像 - prepareForSegue 方法

无法找出发生的原因。

     - (IBAction)cropImageTap:(id)sender {


UIImageView * pickedImage = _chosedImage;
[self dismissViewControllerAnimated:YES completion:^{
[self performSegueWithIdentifier:@"gotomainimage" sender:pickedImage.image];
}];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

PostVC *vc = (PostVC*)segue.destinationViewController;
UIImage *img = (UIImage*)sender;

if (img != nil) {
NSLog(@"its not an null image");
vc.Sourcemage = img;

} else {
NSLog(@"its an null image");
}
}

in my postvc :

@property(nonatomic) UIImage *Sourcemage;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];



if (self.Sourcemage != nil){
NSLog(@"not null dataa");

_PostImageView.image = _Sourcemage;

} else {
NSLog(@"not null dataa");
_PostImageView.image = [UIImage imageNamed:@"Travel.png"];
}


}

最佳答案

目标 View Controller (PostVC)中的变量 Sourcemage 是 UIImage 吗?

请检查该属性是否为 UIImage。

关于ios - UIImage 和 prepareforSegue 无法传递图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50505054/

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