Search code examples
iosswifthyperlinkuibuttonibaction

Is it possible to link two buttons to two different ibactions in the same ViewController?


i work on a project and i have two buttons, one for sending a mail and the second one is an imagepicker.

I've able to link my first button to my @IBAction sendMail but I can't do the same with my @IBAction imagePicker.

When i do a "drag and drop" from the storyboard to the interface file my ViewController nothing happens. The blue strip is here but no window pop up to create the link..

A bit of help would appreciate. Here is the code :

internal class ViewController : UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    override internal func viewDidLoad()

    @IBAction internal func 
         sendEmail(_ sender: any)

    @IBAction internal func 
         imagePicker(_ sender: UIButton)

}


Solution

  • You may have already solved it, but the problem may originate because you are viewing the file interface instead of the file.

    On your storyboard, touch the yellow circle of your ViewController.

    enter image description here

    Then touch the button with the 2 rings in the top right corner of the xCode:

    enter image description here

    Now change from automatic to manual:

    enter image description here

    Finally, find your ViewController without (interface) in the name and connect de action there.

    enter image description here

    If you did it all rigth, now you can see a white circle in the left of your action like this:

    enter image description here