0
votes

I hold device in landscape mode and moved into second view controller, which only support portrait mode. when return back from second view controller(Support all orientation), First view controller is not rotating to landscape mode automatically.

if i did below code then its work in IOS6. but not working for IOS7.

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
    [UIViewController attemptRotationToDeviceOrientation];
}

in IOS7 viewController is rotating but status bar is not rotating

2

2 Answers

0
votes

Implement the following in VC A:

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}
0
votes

The solution presented by AMayes is not quite correct.

The UIViewController docs state the following:

Typically, the system calls this method only on the root view controller of the window or a view controller presented to fill the entire screen; child view controllers use the portion of the window provided for them by their parent view controller and no longer participate directly in decisions about what rotations are supported.

Therefore, put the following code in the UINavigationController subclass:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}