这是我的代码:
@property (weak, nonatomic) IBOutlet UIImageView *chosedImage;
- (IBAction)cropImageTapid)sender {
[self dismissViewControllerAnimated:YES completion:^{
UIImage * pickedImage = self->_chosedImage;
//[UIImage imageNamed"helloWorld.jpg"];
[self performSegueWithIdentifier"gotomainimage" sender:pickedImage];
}];
}
我的表演继续如下:
- (void)prepareForSegueUIStoryboardSegue *)segue senderid)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)cropImageTapid)sender {
UIImageView * pickedImage = _chosedImage;
[self dismissViewControllerAnimated:YES completion:^{
[self performSegueWithIdentifier"gotomainimage" sender:pickedImage.image];
}];
}
- (void)prepareForSegueUIStoryboardSegue *)segue senderid)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)viewWillAppearBOOL)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/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |