如何将情节提要中的多个按钮连接到单个动作?

How to connect multiple buttons in a storyboard to a single action?(如何将情节提要中的多个按钮连接到单个动作?)

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

问题描述

我目前正在使用 Xcode 4.6,我只是想知道如何在不同的 UIView 中选择多个按钮,但在单个视图控制器下.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.

我的最终目标是使用 Xcode 4.6 中的情节提要在两个不同的 UIView 上获得两个不同的按钮以匹配相同的操作.有没有办法做到这一点?

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:

这篇关于如何将情节提要中的多个按钮连接到单个动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何将情节提要中的多个按钮连接到单个动作?

基础教程推荐