使用prepareForSegue将捕获的图像发送到另一个UIViewController

时间:2015-05-13 11:18:15

标签: ios objective-c segue

我正在尝试将捕获的图像发送到另一个Load * Inline [Pay Month Year last 12 months May-2014 Jun-2014 Jul-2014 Aug-2014 Sep-2014 Oct-2014 Nov-2014 Dec-2014 Jan-2015 Feb-2015 Mar-2015 Apr-2015 May-2015 ];

因此,当我按下拍摄按钮时,它正在拍照并且我可以将图像保存在相机胶卷中。但是当我想在另一个视图中看到图像时,我看不到它。

这是我的代码:

UIViewController

这是对segue方法的准备。

- (IBAction)captureButton:(id)sender
{
    [self.cameraViewController captureImageWithCompletionHander:^(id data) {
        self.image = ([data isKindOfClass:[NSData class]]) ? [UIImage imageWithData:data] : data;
        UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
        [self performSegueWithIdentifier:@"savingSegue" sender:self];
    }];
}

2 个答案:

答案 0 :(得分:2)

如果您的第二个视图是prepareForSeque,请将- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"savingSegue"]) { PhotoSaveViewController *pvc = (PhotoSaveViewController *)segue.destinationViewController; if (pvc) [pvc.imageView setImage:self.image]; } } 方法替换为:

UIViewController

事实上,实例化目的地UINavigationController不是你的工作,你的/// <reference path="../../../typings/tsd.d.ts" /> import {Mediator} from '../../../services/remoting/Mediator'; describe('Mediator', () => { let mediator: Mediator; beforeEach(() => { mediator = new Mediator(); }); it('blah blah', () => { expect(mediator.TEST).toBeDefined(); }); }); 已经做到了。

答案 1 :(得分:0)

我猜imageView PhotoSaveViewController @property (nonatomic, retain) UIImage *inputImage; 它是出口而且此刻未设置。你应该声明一些其他属性,如

prepareForSegue

并指定- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"savingSegue"]) { PhotoSaveViewController *pvc = segue.destinationViewController; pvc.inputImage = self.image; } } 中的内容:

PhotoSaveViewController

然后在- (void)viewDidLoad { [super viewDidLoad]; self.imageView.image = self.inputImage; }

中执行以下操作
Storyboard ID

您可以完全从代码创建它的另一种方法。将PhotoSaveViewController分配给- (IBAction)captureButton:(id)sender { [self.cameraViewController captureImageWithCompletionHander:^(id data) { self.image = ([data isKindOfClass:[NSData class]]) ? [UIImage imageWithData:data] : data; UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil); PhotoSaveViewController *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"PhotoSaveViewControllerID"]; dvc.inputImage = self.image; [self.navigationController pushViewController:dvc animated:YES]; }]; } ,然后执行以下操作:

pop(0)