你有从Camera Roll到新的视图控制器的任何方法吗?

时间:2013-11-22 02:36:25

标签: ios uiviewcontroller imageview uiimagepickercontroller

我正试图从Camera Roll转到新的视图控制器。所以基本上我想能够选择一张图片,选择图片后,它会显示在新视图控制器上的imageView上?那很难吗?

-(void) imagePickerController:(UIImagePickerController *)picker  didFinishPickingMediaWithInfo:
(NSDictionary *)info{
self.chosenImage = info[UIImagePickerControllerOriginalImage];
[self.imageView setImage:self.chosenImage];
[self dismissViewControllerAnimated:YES completion:nil];
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
 [self dismissViewControllerAnimated:YES completion:nil];
}

1 个答案:

答案 0 :(得分:0)

在targetViewController中创建UIImage的属性 然后在didFinish方法

中添加以下代码
-(void) imagePickerController:(UIImagePickerController *)picker  didFinishPickingMediaWithInfo:
(NSDictionary *)info
{
    self.chosenImage = info[UIImagePickerControllerOriginalImage];
    [self.imageView setImage:self.chosenImage];
    [self dismissViewControllerAnimated:YES completion:nil];
    TargetViewController *targetViewController = [[TargetViewController alloc]init];
    targetViewController.imageProperty = self.chosenImage;
    [self.navigationController pushViewController:targetViewController animated:YES];

}