Can't connect IBAction in Xcode

前端 未结 12 1576

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:21

    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) {
    }
    

提交回复
热议问题