Ron
Ron

Reputation: 514

iOS App: Window rotation always Portrait instead of Landscape

My app works only in Landscape. Thus I set the Initial Orientation and Supported Orientation at LandScape Home Right.

However, initial launch orientation always becomes Portrait. After navigating to next page and return, the orientation is correct.

This might be the similar question to the following, In IOS 6 on iPad, initial rotation is always portrait, after that it always rotates correctly

But the solution there is not working as the 'handleRotationFor' gives warning: instanceMethod -handleRotationFor is not found (return type defaults to 'id')

How should I fix this error?

Please help

Upvotes: 1

Views: 1721

Answers (4)

Rahul Vyas
Rahul Vyas

Reputation: 28720

In Xcode in the files pane click on your project and then select target from right pane. Then in Summary tab see supported orientations. Only select Landscape right. Also you can implement

-(NSUInteger)supportedInterfaceOrientation {
return UIInterfaceOrientationMaskLandscapeRight;
}

in your app delegate

Upvotes: 1

Prasad_R
Prasad_R

Reputation: 557

Check the supported orientations in the info.plist of the app. Check and set orientations in the nib file as well.

You can check orientations by using [[UIDevice currentDevice] orientation]

Upvotes: 0

crz
crz

Reputation: 458

project Targets --> click on "Summary" tab and choose your Orientation in "Supported interfaces Orientations"

Upvotes: 1

Sam B
Sam B

Reputation: 27598

In Xcode under summary tab make sure portrait and upside down are not pressed down. Also Add these three functions.

// *********************
// ios6 orientation support
// *********************
- (BOOL)shouldAutorotate
{

    UIInterfaceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];


    if (interfaceOrientation == UIInterfaceOrientationPortrait)
    {
        return NO;
    }
    else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        return NO;

    }
    else
    {
        return YES;
    }

}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

    if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        return NO;
    }
    else
    {
        return YES;
    }



}

Upvotes: 0

Related Questions