简体   繁体   English

imageView不显示UIImagePickerController中的图像

[英]imageView doesn't show image from UIImagePickerController

I am trying to programmatically use an image from UIImagePickerController in one view controller and have that be the imageView in another view controller. 我试图以编程方式在一个视图控制器中使用来自UIImagePickerController的图像,并将其作为另一个视图控制器中的imageView。 Here is the method from viewController A 这是viewController A中的方法

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
UIImage *image = info[UIImagePickerControllerOriginalImage];

 bandCropViewController *viewController = [[bandCropViewController alloc]init];
 viewController.imageOriginal = image;
[self dismissViewControllerAnimated:YES completion:^{
 // Move to Crop View Controller
 [self presentViewController:viewController animated:YES completion:nil];
}];
}

ViewController B looks like this: ViewController B看起来像这样:

- (void)viewDidLoad
{
  [super viewDidLoad];
  imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 100, 320, 280)];
  [self.imageView setImage:imageOriginal];
  imageView.backgroundColor = [UIColor redColor];
  [self.view addSubview:imageView];
}

viewController B is showing the imageView frame in red as it should be. viewController B正以红色显示imageView框架。 But the image is not carrying over. 但是形象没有延续。

Any thoughts as to what I am doing wrong? 关于我在做什么错有什么想法吗?

Highly recommend this tutorial 强烈推荐本教程

It should help you out. 它应该可以帮助您。 It looks like you are possibly doing some unnecessary things in 看来您可能正在做一些不必要的事情

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM