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.
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?
EDIT: I'm currently using Xcode 4.6.1 without any luck, upgrading to 4.6.2.
In Xcode 5, after setting action for the 1st button, I have to build the app. This then allows me to connect other buttons action to this same IBAction method
You can use
IBOutletCollection
the following link will help you in using thathttp://useyourloaf.com/blog/2011/03/28/interface-builder-outlet-collections.html
Swift 3.0 Xcode 8.0+
Connect all buttons to below method signature. Make sure argument sender is of type UIButton (Or subclass of UIButton) in-order to connect rest of the buttons from storyboard.
Use sender.tag to identify the tapped button.
Follow this steps
1. Create IBAction In View Controller
In .h file
In .m File
2 . Connect all button to this action
3 . Give Each Button a tag by follow the next Picture
4 . Now inside your action function put these
Run and Go.
You should be able to do this in IB. In IB, simply point them at the same
IBAction
in the relevant class.When the action comes, in case you want to know from which button you got the action, you can then differentiate between the buttons within the
IBAction
method either by reading the text from the button or using thetag
attribute which you should have set from IB.in xcode 4.6.3 you no more need to save before assigning action.