了解performSegueWithIdentifier [英] Understanding performSegueWithIdentifier

查看:186
本文介绍了了解performSegueWithIdentifier的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人比我解释 performSegueWithIdentifier:sender:对我更有见识吗?我需要切换视图(和类),并将一些NSStrings和ID带到该视图的类。我想知道这是否可以使用 performSegueWithIdentifier:sender:

Can someone more knowledgeable than I explain performSegueWithIdentifier:sender: for me? I need to switch views (and classes) and also carry a few NSStrings and IDs over to that view's class. I was wondering if this is possible with performSegueWithIdentifier:sender:

谢谢!

推荐答案

首先,您必须在故事板中设置segue并为其指定适当的标识符。 (单击segue(左侧面板),然后单击属性(右侧面板)。

First, you have to have set up the segue in your storyboard and give it the appropriate identifier. (Click on the segue (left panel) and then click on Attributes (right panel).

然后,您可以将其链接到故事板中的按钮或选择表行,或者您可以使用 performSegueWithIdentifier:sender:来代码调用它。

You can then link this to buttons or selection of table rows from your storyboard, or you can call it in code using performSegueWithIdentifier:sender:.

此后,您的视图控制器将被发送 prepareForSegue:sender:消息。您在视图控制器子类中重写此方法,并可以按如下方式配置目标视图控制器:

After this, your view controller will be sent the prepareForSegue:sender: message. You override this method in your view controller subclass, and can configure the target view controller as follows:

TargetViewController *targetVC = (TargetViewController*)segue.destinationViewController;
targetVC.string1 = string1;

依此类推。此方法中的 sender 将是您用作<$ c $的对象c>发件人在原始方法调用中。

And so forth. The sender in this method will be the object that you use as the sender in the original method call.

这篇关于了解performSegueWithIdentifier的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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