0

In my Application one of the ViewController is need to be supported from portrait to landscape/landscape to portrait, and remains support to portrait only I achieved this in Xcode 4.6 with iOS 6 but when I run my code in Xcode 5 with iOS 7 those methods are not being called. Is there any methods deprecated in iOS 7. If yes what are those methods?

I have created a sub class for UINavigationController and below is the my code which is working fine in iOS 6.

-(BOOL)shouldAutorotate
{
  return [[self.viewControllers lastObject] shouldAutorotate];
}

-(NSUInteger)supportedInterfaceOrientations
{
  // return [[self.viewControllers lastObject] supportedInterfaceOrientations];
   return [[self topViewController] supportedInterfaceOrientations];

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return [[self.viewControllers lastObject]     
                         preferredInterfaceOrientationForPresentation];
}  

Please help me. Thanks in advance.

Ganesh G
  • 1,991
  • 1
  • 24
  • 37
  • Have you checked these? http://stackoverflow.com/questions/13357156/change-uiinterfaceorientation-for-only-one-uiviewcontroller-in-app-ios-solved http://stackoverflow.com/questions/19905088/ios-7-change-page-orientation-only-for-one-view-controller http://stackoverflow.com/questions/18980853/force-landscape-orientation-in-one-view-controller – Neeku Nov 29 '13 at 10:12
  • These answers are saying that we are forcefully changing the orientation. But my case is if user rotate then it will rotate. – Ganesh G Nov 29 '13 at 12:05

2 Answers2

0

Have you checked this mark these all device orientations

Gurpreet
  • 181
  • 6
0

oky, in the viewcontroller that needs to support landscape use the following code


 - (BOOL)shouldAutorotate
 {
     return YES;
 }

  - (NSUInteger)supportedInterfaceOrientations
 {
      return UIInterfaceOrientationMaskLandscape;


 }

  - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
 {
     return UIDeviceOrientationLandscapeLeft; //which side u want weather left or rite

 }


and view controllers that supports portrite


 - (BOOL)shouldAutorotate
   {
      return NO;
   }

   - (NSUInteger)supportedInterfaceOrientations
   {
        return UIInterfaceOrientationMaskPortrait;
   }

   - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
   {
        return UIDeviceOrientationPortrait;

   }


you hav to set the supported orientations as @Gurpreet said ..

try this, hope this helps u :)

Shankar BS
  • 8,394
  • 6
  • 41
  • 53