Interface rotation processing in iOS 7

A very simple question, but I ask how it seems that there are many conflicting views, and I could not completely find the final answer, not to mention the modern one.

I use Auto Layout for 99% of my user handling, changing from portrait to landscape or vice versa UIViewController. It works great. But sometimes I have to rely on frames for one reason or another.

How do I deal with this?

Do you have methods willAnimateRotationToInterfaceOrientation, willRotateToInterfaceOrientation, NSNotificationchecking the status bar, and I'm sure there are others.

If I want to change the position of the view when the user rotates, which method should I change in the frame? And is it better to do this with a simple one setFrame:or use autoresist masks?

+4
source share
2 answers

Since iOS6, you should not use willRotateToInterfaceOrientation:and didRotateFromInterfaceOrientation:. They are called only on the front most-represented view controller and will not be called on others. This means that if you have a pressed view controller or a view controller presented, all others will not display correctly.

Instead, you should always use viewWillLayoutit viewDidLayoutto handle rotation. They are both called inside the animation block, so anything you do that is animated will be animated.

, viewDidLayout. , . constant.

+5

, willRotateToInterfaceOrientation, . subviews, layoutSubviews .

, , , - , .

willRotateToInterfaceOrientation didRotateFromInterfaceOrientation , , (, ). layoutSubviews, .

, , - , iOS ( ).

-1

All Articles