我正在尝试从图像库中选择一个图像,然后通过UIImagePickerControllerOriginalImage选择它,然后将其传递到另一个视图,但是它不起作用。我总是在另一页中得到一个空的UIImageView。可能是我的问题?

MainPageVeiwController.m:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {

    FormViewController *second = [[FormViewController alloc] initWithNibName:@"FormViewController" bundle:nil];

    [self dismissModalViewControllerAnimated:YES];

    [second.imageView setImage:[editingInfo objectForKey:UIImagePickerControllerOriginalImage]];

    [self.navigationController pushViewController:second animated:YES];
}


FormViewController.m:

@property (strong, nonatomic) IBOutlet UIImageView *imageView;

最佳答案

问题在于,当您尝试访问imageView时,尚未加载FormViewController的视图,因此它将为nil。您应该在FormViewController中创建UIImage属性,然后传递图像。让FormViewController在viewDidLoad中填充其自己的图像视图。

关于ios - 将图像从主 View 传递到另一个 View 问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24868857/

10-10 22:25