sinoptic
sinoptic

Reputation: 303

UIView changes when iphone application starts from background

My iphone application has a user form under UIViewController.

When I out of application (go to background mode) and start application again some of my UIView changes its positions and sizes. (These UIViews depend on keyboard position) Definately somewhere is my fault.

I try to figure what is going on when application starts again from background and where the UIView changes can be done.

May be you can suggest any links to read.

Thank you.

Upvotes: 0

Views: 393

Answers (1)

Matthew Frederick
Matthew Frederick

Reputation: 22305

The UIViewController's viewDidLoad and viewWillAppear methods get called every time the view is dumped from memory, something that commonly happens when the app goes into the background. Depending on your code, it's possible that you're storing some position data that's not getting cleared. If that's the case, you can either:

  1. Change your code to better fit the Model-View-Controller pattern so that the positioning code and variables are all in the controller, and you appropriately clean things up in its 'viewWillDisappearandviewDidUnload` methods (the better way), or

  2. Clear out whatever remnants are hanging around in your application delegate's applicationWillEnterBackground method.

Upvotes: 1

Related Questions