Search code examples
iosobjective-cuiimagepickercontroller

Perform different function based on button that activates UIImagePickerController


I have two buttons, and when each is pressed, a UIImagePickerController will appear.

I can select and retrieve the photo just fine. However, I want to do something different based on which button started the action.

Is there a way to determine which button caused the initial UIImagePickerController to appear in the didFinishPickingImage call?


Solution

  • There is no magic. You need to somehow save your state, and when the delegate method is called, determine your state and act accordingly. The easiest here, is to add a property or instance variable to your controller and update it with a unique value (such as enum) for each button.