Assume in an app you have 2 UIButton‘s, buttonA and buttonB. If you want to call the FlipsideViewController from these 2 buttons, where the only the difference will be the background images. (i.e.: if buttonA is pressed, BackGroundA will appear in the FlipsideViewController‘s view, otherwise, it will be BackGroundB.)
Now the First BackGround (BackGroundA) is set by default. How do I handle the second background image (BackGroundB) if buttonB is pressed?
Depending on how you are presenting FlipsideViewController, a couple of ways are:
“background” could be an int or enum property/parameter and then the code in FlipsideViewController will do whatever it needs to itself based on that value.
Edit:
To use the property approach:
First, in FlipsideViewController, make sure you have an IBOutlet for the UIImageView called say
backgroundImageView.Next, in FlipsideViewController.h, add a property to set the background (I’m using an int):
Next, in FlipsideViewController.m, add this:
Finally, in the main view controller, the button action method would look something like this: