When I drag from a button on the storyboard to my view controller Swift file, I only get the option to insert an Outlet or Outlet Collection.
Similarly, if I create the
I was having the same issue but it was because I was trying to connect an ImageView to an IBAction (forgive me, not sure if my terminology is correct). I deleted the ImageView object and replaced it with a Button and IBAction then became an option rather than just IBOutlet and Outlet Collection.
For me, I was trying to connect multiple buttons to one IBAction
, none of the solutions worked until I switched my method signature to specify that the sender was a UIButton
rather than Any
@IBAction func buttonPressed(_ sender: UIButton) {
}
This apparently is a known issue on the Apple forums, but I don't know if Apple is working on it:
https://forums.developer.apple.com/message/216258
Here is what I did for a workaround.
pod update
to remove the pod from the project. pod update
to reimport the pods. I can't speak to the underlying cause--something always seems to be breaking in XCode, but you can always write your IBAction manually, @IBAction func(sender: UIButton) { }
in your view/controller and then control-drag from the storyboard element to the action itself. If that doesn't work try linking from the node created by an IBAction in the margin of your code back to the storyboard. This works for me when XCode stops working.
Alright, it's 2019 and this problem still happens and if anyone is here still looking for a solution, the only way i could get it to work is to:
For me, it was a FUIButton (custom from SAP Fiori) causing same issue. No pods or UIButton extension specified in my own code (in addition to SAP UIButton obviously). Cmd + Alt + Shift + K, DerivedData Clean didn't help either. @IBAction wasn't available in Interface Builder till I changed my Button Class back to simple UIButton.
And... voila! ta-da!