0

I'm trying to make an app that has multiple buttons to perform the same "take a picture" action. The only think that will different with each button is that where I want the picture to be displayed. I have six buttons and I want them to display six different pictures on the same VC. I put in the Storyboard VC to show what I am looking to do. Here is my code for my first button, but I am trying to make every button do the same thing without retyping this every IBAction. Thanks!

@IBAction func photoBtnPressedOne(_ sender: AnyObject) {
    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
        let imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = UIImagePickerControllerSourceType.camera;
        imagePicker.allowsEditing = false
        self.present(imagePicker, animated: true, completion: nil)
}
Darin Wilson
  • 169
  • 1
  • 2
  • 9
  • Could you add the implementation of how you are taking the photo for a single in a code snippet? – Ahmad F Nov 15 '16 at 15:54

1 Answers1

2

What's the question? If you want to know how to have multiple buttons perform the same action, here's a link to a SO question from a year ago.

If you want to know how to have the action know which button was pressed, assign a unique tag property to each button and put code inside your action to use it.

Community
  • 1
  • 1