简体   繁体   中英

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.

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 'viewWillDisappear and viewDidUnload` methods (the better way), or

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM