单独的Button动作和segue动作 [英] Separate Button action and segue action

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

问题描述

按下按钮时我必须按下新的segue。但我也有一个附加的动作,需要在推动segue之前触发。

I have to push a new segue when a button is pressed. But i also have an action attached to it that needs to be triggered before the segue is pushed.

你能告诉我如何将它们彼此分开吗?任何帮助,将不胜感激。

Can you tell me how to separate them from each other? Any help would be appreciated.

推荐答案

将segue直接从一个视图控制器转到另一个视图控制器,而不是将其连接到按钮。给它一个有意义的名字。

Make the segue directly from one view controller to the other instead of connecting it to the button. Give it a meaningful name.

然后,在按钮的操作方法中,首先执行您需要执行的操作,然后使用视图控制器的 performSegueWithIdentifier执行segue:方法,使用您之前选择的有意义的名称。

Then, in your button's action method, perform whatever you need to do first, then perform the segue using your view controller's performSegueWithIdentifier: method, using the meaningful name you chose earlier.

从您的评论中,您似乎正在尝试在视图控制器上设置即将从您的segue中显示的属性。如果是这种情况,你应该实现 prepareForSegue:,并使用 segue.destinationViewController 来获取指向视图的指针即将出现的控制器。

From your comments, it seems like you're trying to set properties on the view controller that is about to appear from your segue. If this is the case, you should implement prepareForSegue:, and use segue.destinationViewController to get a pointer to the view controller that is about to appear.

这篇关于单独的Button动作和segue动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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