views:

74

answers:

2

I am going insane! This is a simple app with two Views. FirstView is a text field with info button to flip to SecondView. In SecondView I have 6 buttons for background color choice. When button is pushed the color of background changes perfectly but cannot make it also change background color for FirstView. Any help would be GREAT! Thanks! I am using Objective C class working on a iPhone app. Sorry new at this. The SecondView acts almost like a settings page in the fact that when a button is pushed the background color changes to the button color. I need it so when I push the "back" button to go back to FirstView the background color has also changed to that color choice. Been thru sooooooooo many tutorials and codes that now I am totally lost......... Thanks again!

A: 

What about saving the color change to the NSUserDefaults and then in the other view's viewWillAppear: method you read them back and set the background color?

Or, show some code.

St3fan
Thanks for getting back to me. In SecondView I have -(IBAction)red; -(IBAction)blue; in .h In .m I have -(IBAction)red { self.view.background = [UIColor redColor]; } So not sure what to put in FirstView to make it read color choice when button is pusher in SecondView. Thanks again for getting back to me.
rob
A: 

Assuming you have references to both views (lets call them firstView and secondView), and assuming you're doing something like this to set the background color of your SecondView:

secondView.backgroundColor = [UIColor whiteColor];

Just do the same thing for the firstView:

firstView.backgroundColor = [UIColor whiteColor];

Replacing [UIColor whiteColor] with whatever you're setting the background color to. Or am I misunderstanding your question?

macatomy
I am using-(IBAction)red { self.view.background = [UIColor redColor]} then blue, green, so on. Not seeing how to make FirstView recognize button push in SecondView so FirstView background color also changes.
rob
GOT IT! All I had to do was add parentViewController. to the set background! Thanks so much for your help!
rob