views:

133

answers:

1

I'm working on a simple iPhone App and in some cases it has a very weird behavior which I just cannot understand...

The App has an UIImageView and a few controls like a switch, label, progresbar etc. These control are initially in certain states, like the switch is off, the label contains some initial text, the progresbar is hidden. These states will eventually change during an interaction with user.

After a while the App should take a picture with the camera. This picture will be assigned to my UIIMageView. There is only one delegate controller for all objects (why not?).

And now comes the problem: after taking the picture with the camera and assignment of it to the image view, all controls return to their initial states...

When I comment the one line out, where the image will be assigned to my UIImageView:

imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

the states of the controls won't change! So it's caused only by the image assignment but why ?!

Any ideas?

+3  A: 

It sounds like you're setting the states of the controls in viewDidAppear:.

When you display the image picker, your view disappears, and is sent viewWillDisappear: and viewDidDisappear:. Consequently, when you dismiss the image picker, your view is sent viewWillAppear: and viewDidAppear:.

If you're setting the states of the controls in that method, then they'll be reset whenever those methods are called.

Maybe consider moving the code to set the control states into viewDidLoad.

Jasarien