Can't connect IBAction in Xcode

前端 未结 12 1698

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

12条回答
  •  轮回少年
    2021-02-02 13:27

    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:

    • Write your IBAction function in the extension
    • In Interface Builder, tap File's owner or the main view
    • On the Right toolbar click on the Connections Inspector

    • go down the list and find the IBAction you created, sitting there all alone and not connected to anything
    • Click on the empty circle next to it and drag to your sad sad button

    • See that sad button is now happy again and connected to something

提交回复
热议问题