How to get default LandscapeLeft Orientation in iOS5?

Sorry if this question is duplicate, but I can’t find the same solution.
In iOS6, if I want to set default orientation for one UIViewController, I just use:

- (BOOL)shouldAutorotate {
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

But how to do same in iOS5, I test both:

  • Debugger lldb says my object is nil when is not ?
  • Icon gloss with iOS 6 & Xcode 5.0
  • unused variable warning when variable is actually being used
  • CAShapeLayer mask view
  • In 10. power / calculation / Power calculations
  • Missing iOS symbols at “~/Library/Developer/Xcode/iOS DeviceSupport”
  • - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
        return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);//not default
    }
    and
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
        return (toInterfaceOrientation == UIInterfaceOrientationMaskLandscapeLeft);// = return NO;
    }
    

    But the default orientation always Portrait.Any suggestion?

    4 Solutions Collect From Internet About “How to get default LandscapeLeft Orientation in iOS5?”

    call the below method where you want to check the status of orientation.happy coding 🙂

    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
        [self CheckForViewForOrientation:toInterfaceOrientation];
    }
    
    - (void) CheckForViewForOrientation:(UIInterfaceOrientation)orientation
    {
        if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
        {
            //Ur lable portrait view
        }
        else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
        {
            //Ur lable for landscape view
        }
    }
    

    If you want to achieve this for whole application, change supported orientation UISupportedInterfaceOrientations in app.plist file

    - (BOOL)shouldAutorotate {
    
    UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
    
    if (orientation==UIInterfaceOrientationPortrait) {
     // do some 
    
    }
    
    return YES;
    }
    

    Include both the methods to support both 5 and 6

    You need to provide

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
         UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    

    for that single View controller.