如何将故事板中的多个按钮连接到单个动作? [英] How to connect multiple buttons in a storyboard to a single action?

查看:84
本文介绍了如何将故事板中的多个按钮连接到单个动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Xcode 4.6,我只是想知道如何在不同的UIViews中选择多个按钮,但是在单个视图控制器下。 CMD点击似乎不起作用。我需要这个功能,因为在Xcode 4.6中,让IB上的两个按钮共享相同动作的唯一方法是一次选择它们然后将动作拖动到视图控制器。

I'm currently using Xcode 4.6 and I'm simply wondering how to select multiple buttons across different UIViews, but under a single view controller. CMD clicking doesn't seem to work. I need this functionality because in Xcode 4.6 the only way to let two buttons on IB to share the same action is to select them at once and then drag the action to your view controller.

我的最终目标是在两个不同的UIViews上获得两个不同的按钮,以使用Xcode 4.6中的故事板来匹配相同的动作。有没有办法做到这一点?

My ultimate goal is to get two different buttons on two different UIViews to match the same action using storyboards in Xcode 4.6. Is there a way to do this?

编辑:我目前正在使用Xcode 4.6.1而没有任何运气,升级到4.6.2。

I'm currently using Xcode 4.6.1 without any luck, upgrading to 4.6.2.

推荐答案

您可以将多个按钮连接到单个操作,而无需一次选择所有按钮。

You can connect multiple buttons to a single action without selecting them all at once.

但是,在创建操作之后,您需要保存包含操作的源文件,然后Xcode才会允许您将另一个控件连接到操作。

However, after creating the action, you need to save the source file containing the action before Xcode will let you connect another control to the action.

我使用Xcode 4.6执行此操作.2:

I did this with Xcode 4.6.2:

这篇关于如何将故事板中的多个按钮连接到单个动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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