IOS: rotation orientation check on ViewDidAppear

Background: . I want to make sure my viewControllers rotate correctly when it appears. My viewControllers have excellent codes that control rotation and orientation when visible.

Problem: Given the two view modes in the NavigationController, viewC1and viewC2. I have done the following:

1.) Set rootViewController to viewC1

2.) Click viewC2in NavigationController

3.) Turn

4.) Pop viewC2

5.) viewC1still stuck in the old orientation (as in the conversion code is willAnimateRotationToInterfaceOrientationnot called in) with the new orientation.

What can I do to provide a viewC1challenge willAnimateRotationToInterfaceOrientation, to restore myself, to look correctly in the new rotation?

Additional Information: This is all code (without storyboard / xib). I have a shouldAutorotateToInterfaceOrientationreturn YESfor all views. I use willAnimateRotationToInterfaceOrientationto control all my rotation.

Oh, and please, no hacks. For example, copy the code from the rotation, then check the rotation in manual mode and control it in viewDidAppear.

+3
source share
1 answer

Think about the name of the method and what you are trying to achieve.

willAnimateRotationToInterfaceOrientation , , , . , . -, , . , , , UIKit . , - ( ), . , ( " ", ).

, , , , , . -(void) updateLayoutForOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated { ... } . .

, / ,

-(void) viewWillAppear:(BOOL)animated

-(void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation duration: (NSTimeInterval) duration

updateLayoutForOrientation:animated:, .

+1

All Articles