5

hope you will be fine and doing your best.

I am getting a problem in upSideDown Orientation in my iOS 6, while I think I am doing everything perfect, but I don't know why it is not working for me. I am sharing my problem with you so to get any solutions.

What I have done so far:

a) In xcode project Summary tab, I have enabled all the 4 orientations.

b) I have added piece of code (written below) in all of my controller classes.

-(BOOL)shouldAutorotate
{
    return YES;
}
-(NSInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

but still the upSideDown Orientation is not working

Thanks in anticipation.

iOmi
  • 625
  • 10
  • 24

1 Answers1

8

I have found its solution.

We need to make a separate class of UINavigation Controller type. In .m file add the following methods

// Deprecated in iOS6, still needed for iOS5 support.
// ---

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    //    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    return YES;
}

// iOS6 support
// ---
- (BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskAll;
}

Now assign this newly created class to your Navigation Controller in story board. Also add the .m file of this class in 'Project -> Build Setting -> Compile Sources'. Run the project and it will support and perform all the orientations including upSideDown.

I hope it will help you all.

Regards

iOmi
  • 625
  • 10
  • 24
  • An alternative is to create a category on `UINavigationController` as done here: http://stackoverflow.com/a/16052448/211292 – ThomasW Jul 31 '13 at 05:08
  • I need it only for iPhone with iOS 7 to detect PortraitOrientationUpSideDown. – Beto Jan 07 '14 at 18:08