所以我正在构建一个IOS应用程序,我有一个图片库,当你按下一张照片时,它会注册,你可以用它做一些事情。基本上,我需要的是当用户按下该照片时,我需要它打开另一个屏幕(segue),我需要在新屏幕上知道被按下的特定照片是什么,并设置一个屏幕大小的UIViewController作为该照片。我目前拥有的代码是
PhotoEditorViewController *editor = [[PhotoEditorViewController alloc] init];
ALAsset *asset = self.assets[indexPath.row];
ALAssetRepresentation *defaultRep = [asset defaultRepresentation];
editor.img = [UIImage imageWithCGImage:[defaultRep fullScreenImage] scale:[defaultRep scale] orientation:UIImageOrientationRight];
NSLog(@"Photo Pressed");
NSLog(@"%@", editor.img);
[self presentModalViewController:editor animated:YES];所以现在要做的就是获取按下的图片,并设置我的UIImage变量。"img“作为图像,然后当UIImageViwer被调用时,我可以在其他屏幕上看到图像传输的viewDidLoad方法,但由于某些原因,我无法将该图像设置为img。
NSLog输出:
在屏幕1和屏幕2上都显示了UIImage 0x#######
这让我相信照片ID信息正在传输,但它并没有更新uiimageview
ViewDidLoad
{
NSLog(@“%hhu%”, editorPhoto);
[image setImage:editorPhoto];
}发布于 2018-02-03 12:15:41
在nextViewController.h文件中创建属性。
@property (strong, nonatomic) UIImageView *imgView;从这里传递图像。
- (IBAction)nextView:(UIButton *)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
myViewController *VC = [storyboard instantiateViewControllerWithIdentifier:@"myViewControllerID"];
VC.imgView.image = [UIImage imageNamed:@"image.jpg"];
[self.navigationController pushViewController:VC animated:YES];
}https://stackoverflow.com/questions/46019755
复制相似问题