Persistent UIView Animation with Autolayout

I have a UIView inside the UIViewController called “A”. There animations been applied to this view, mostly frame been updated. So far so good without any trouble. Now I navigate to next screen by performing regular segue. When I return back to original “A” then last updated frame position of view gets reset to original position. Why this was happening ? It got reset always even after writing lotsa crazy unnecessary codes. First relevant point appeared was that I am using autolayout, Could this be the reason behind this behaviour ? Yes this was the case. It looked like Autolayout updates the frames to original position according to all layout contraints that is added to it.

What solution i implemented ? This one line:

myView.translatesAutoresizingMaskIntoConstraints = YES;

I hope this post helps others to who is facing similar problem.

EDIT (29 june, 2015):
The above is not reliable method. The best approach is to change the constants of constraints that influence your animations and then simply commit the layout changes, described well in this post http://stackoverflow.com/questions/13296232/ios-how-does-one-animate-to-new-autolayout-constraint-height

I will write a separate post of my learning on autolayout animation.

Be the first to leave a comment. Don’t be shy.

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>