iPad – WillrotateTointerfaceorientation does not call from the presentation of ViewController

I use this configured uiviewcontroller on the ipad:

shouldAutorotate(true)
supportedInterfaceOrientations(UIInterfaceOrientationMaskAll)
and in willRotateToInterfaceOrientation Perform some tricks to adjust my interface.

From a child of this controller, I showed a QuickLookController with this-poor-code.

< pre>[[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:previewController animated:YES completion:nil];

However, if I rotate my iPad, the method will not be able to call RotateToInterfaceOrientation, so I can’t adjust the interface skills.

Can someone explain me or give me some suggestions? Thank you

Reason:
There may be many possibilities for this problem.

1) If the viewController of your view is a subview of some other rootViewController, it is not a navigationController, then the rotation call may not be propagated to the controller of the subView.

2) In a certain I read that if the super method is not called correctly where needed, then it may be the cause of the rotation problem, which means that all ViewControllers related to automatic rotation in the view stack must call the super method in the method implementation (i.e. from the viewDidLoad of ViewController Call [super viewDidLoad].

You can use the following techniques to handle orientation changes.

Register the notification program in viewWillAppear.

-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];)

Direction change The following functions will be notified.

- (void)orientationChanged:(NSNotification *)notification{
[self handleOrientation:[[UIApplication sharedApplication] statusBarOrientation]];}< /pre>

This will call the following method, where you can handle orientation changes.

- (void) handleOrientation:(UIInterfaceOrientation) orientation {
< br /> if (orientation == UIInterfaceOrienta tionPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
//handle the portrait view
}
else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
//handle the landscape view
}
}

I use this configured uiviewcontroller on the ipad:

< /p>

shouldAutorotate(true)
supportedInterfaceOrientations(UIInterfaceOrientationMaskAll)
And in willRotateToInterfaceOrientation I perform some tricks to adjust my interface.

From a child of this controller, I A QuickLookController with this-poor-code is shown.

[[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:previewController animated:YES completion:nil ];

But if I rotate my ipad, the method will not be able to call RotateToInterfaceOrientation, so I can't do the skills to adjust the interface.

Can someone explain me or give me some suggestions NS? Thank you

Reason:
There may be many possibilities for this problem.

1) If your view is viewController is a subview of some other rootViewController, it is not a navigationController, then the rotation call may not be propagated to the controller of the subView.

2) Somewhere I read that if it is not called correctly where needed Super method then it may be the cause of the rotation problem, which means that all ViewControllers related to automatic rotation in the view stack must call the super method in the method implementation (that is, call [super viewDidLoad] from ViewController's viewDidLoad.

You can use the following techniques to handle orientation changes.

Register the notification program in viewWillAppear.

-(void)viewWillAppear:(BOOL)animated{ 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];}

Orientation changes will notify the following functions.

- (void)orientationChanged:(NSNotification *)notification{
[self handleOrientation:[[UIApplication sharedApplication] statusBarOrientation]];}

This will call the following method, You can handle orientation changes here.

- (void) handleOrientation:(UIInterfaceOrientation) orientation {

if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUps ideDown)
{
//handle the portrait view
}
else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
/ /handle the landscape view
}
}

Leave a Comment

Your email address will not be published.