如何使用segue通过拍摄的照片 [英] How to use segue to pass taken photo

查看:101
本文介绍了如何使用segue通过拍摄的照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将在第一视图控制器中拍摄的照片传递给第二视图控制器.我希望用户在第一个视图控制器中拍照,然后在第二个视图控制器中裁剪,然后保存.我只想做这个简单的任务,但花了我几天时间才能使segue正确执行..segue是执行此任务的最佳方法吗?还是有更简单的方法来执行此任务.我是物镜-c的初学者,因此它使我对segues和所有其他东西感到困惑.

I want to pass a photo taken in the first view controller to a second view controller. I want the user to take the photo in the first view controller and then crop in in the second view controller and then save.. So its like.. User take photo→crop→save. I just want to do this simple task but taking me days to get the segue go right.. Is segue the best way to do this? or is there a more easier way to do this task. I am a beginner in objective -c so its making me confused with segues and all the stuff.

推荐答案

就segue而言,您需要使用情节提要通过将箭头从第一个视图控制器拖动到第二个视图控制器来创建一个segue箭头,最重要的是,您需要给segue一个标识符或名称.

As far as segue is concerned you need to create a segue arrow using storyboard by dragging arrow from first view controller to second view controller, and most importantly you need to give the segue an identifier or name.

您可以通过编程方式进行解雇,例如:

For firing you segue you may do it programatically, like:

[self performSegueWithIdentifier:@"ShowSecondScreen" sender:self];

要在触发segue时处理事情,您需要编写prepareForSegue()方法,您可以将任何对象从当前viewController传递到下一个viewController:

For handling things when segue is fired you need to write prepareForSegue() method, you may pass any object from current viewController to next viewController:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"ShowSecondScreen"])
    {
        SecondViewController *secondViewController = segue.destinationViewController;
    secondViewController.imageObj = image;
    }
}

这篇关于如何使用segue通过拍摄的照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆