Reputation: 1202
I found strange issue under storyboard;
I have dragged UIImageView
, which passed to necessary frame inside UIView
(and can return back). To do this, I subclassed UIImageView
and changed frame inside touches delegates. Everything works if I don't change current view.
After view flipped and return back, I seen objects at a same positions, like nothing was happened before:
I can store internally all object's positions, but why iOS don't save all frame changes?
Upvotes: 0
Views: 154
Reputation: 124997
It's likely that the view was released when you switched to a different view and reloaded when you switched back. The new view had new subviews, of course, and each of those was positioned according to the data in the storyboard or .xib file.
A cardinal rule in iOS development is that you shouldn't use views to store application state. If the positions of the views needs to be preserved, you should store those positions in the app's model. The view controller should implement the -viewDidLoad
method to fetch the positions from the model and set the subviews accordingly.
Upvotes: 1