iOS 6 - 我可以在解开segue时返回数据吗? [英] iOS 6 - can i return data when i unwind a segue?

查看:80
本文介绍了iOS 6 - 我可以在解开segue时返回数据吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用故事板工具创建了一个简单的展开segue。我已创建在我想放松到视图以下事件处理程序:

I have created a simple unwind segue using the storyboard tools. I have created the following event handler in the view I want to unwind to:

-(IBAction)quitQuiz:(UIStoryboardSegue *)segue {
    NSLog(@"SEGUE unwind");
}

这会正确触发并解开segue(消息会被记录)。

This fires correctly and unwinds the segue (the message gets logged).

当用户退出测验时,我想传回一些数据并且一直在努力解决这个问题。任何人都可以建议吗?

When the user quits the quiz I would like to pass some data back and have been struggling with how to achieve this. Can anyone advise?

推荐答案

谢谢杰夫。观看了 WWDC视频407 后,我有一个明确的解决方案。

Thanks Jeff. After watching WWDC video 407 I have a clear solution.

在作为展开目标的视图控制器中,你应该创建一个方法,获取单个UIStoryboardSegue参数并返回IBAction。 UIStoryboardSegue有一个返回源视图控制器的方法!这里是从视频(信用苹果)所采取的例子

In the view controller that is the target of the unwind you should create a method that takes a single UIStoryboardSegue parameter and returns an IBAction. The UIStoryboardSegue has a method to return the source view controller! Here is the example taken from the video (credit to Apple).

- (IBAction)done:(UIStoryboardSegue *)segue {
    ConfirmationViewController *cc = [segue sourceViewController];
    [self setAccountInfo:[cc accountInfo]];
    [self setShowingSuccessView:YES];
}

这篇关于iOS 6 - 我可以在解开segue时返回数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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