0

Team,

My application is not responding to Orientations from iOS 7 onwards. I was trying to push the screen through pushViewController, then later I changed to presentViewController

before [viewController.navigationController pushViewController:landscapeCommentScreen animated:animated];

After iOS7 upgrade:

 [viewController.navigationController presentViewController:landscapeCommentScreen animated:YES completion:nil];

added the below methods in view controller

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}


- (BOOL) shouldAutorotate {
    return YES;
}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight;
}
Ramesh Sangili
  • 1,633
  • 3
  • 17
  • 31

1 Answers1

1

You should not return UIInterfaceOrientationMaskAll in supportedInterfaceOrientations. You should return UIInterfaceOrientationLandscapeRight.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
  • @RameshSangili Look at my answer here: http://stackoverflow.com/a/16022631/983912 for a full example project with exactly what you need. – Léo Natan Mar 13 '14 at 21:55
  • I tried, it is not working. I am building the UI screens on top of a framework, I am not sure whether is restricting the Orientation support. Is there anyways to override the code in the framework to support for orientation change? I did a sample application and there it works fine. – Ramesh Sangili Mar 20 '14 at 21:00
  • @RameshSangili If the framework opens your view controller in modal, that should be enough for your to control the orientation of your view controller. – Léo Natan Mar 20 '14 at 21:01
  • Hi Leo, I tried a sample application using my framework and device responds to Orientation change. But When I try with this application which was already built by other developers, I am seeing an issue wit Orientation. The device always shows in Portrait mode irrespective of the Orientation change. Any thoughts? – Ramesh Sangili Mar 28 '14 at 17:43
  • Perhaps the app defines only portrait orientation as supported in its plist. – Léo Natan Mar 28 '14 at 17:45
  • We already added for LandscapeLeft and LandscapeRight in Plist file and also in General Settings to support for Landscape Left and Right – Ramesh Sangili Mar 28 '14 at 17:57
  • I resolved the issue with 3rd party framework, I just would like to know, how to enable Landscape Orientation only on Specific screens? As of now, I selected Landscape Left and Right options in General Settings and enabled in Supported interface orientations (iPhone) in plist file for the device Orientation, but that impacts all the screens. I have nearly 80 screens in my application, I need to support both Portrait and Landscape about 5 screens, rest of the screens should be shown only in Portrait mode. Any help is greatly appreciated! Thanks, Ramesh – Ramesh Sangili Mar 31 '14 at 17:38
  • @RameshSangili See my answer here: http://stackoverflow.com/a/16022631/983912 including an example project. – Léo Natan Mar 31 '14 at 18:34
  • Thank you Leo. Am I suppose to override the below method in 80 screens? - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; } – Ramesh Sangili Mar 31 '14 at 19:19
  • Well, I am not familiar with your design. In a case like this, I would create a subclass of `UIViewController` and implement there, and use that as my subclass for the view controllers in question. – Léo Natan Mar 31 '14 at 19:21
  • Hi Leo, our framework extend UIViewController and we extend FramewworkUIViewController class to design the screen. I added a category to FrameworkUIViewCOntroller and added the supportedInterfaceOrientation to lock it only portrait mode, but that is not working :(... – Ramesh Sangili Mar 31 '14 at 19:54
  • view controller is pushed.. I added a category and override AutoRotate and supportInterfaceOrientations, but what I observed shouldAutoRotate is not being called at all, it calls only supportInterfaceOrientation.. Any idea why? – Ramesh Sangili Mar 31 '14 at 20:18
  • You cannot enforce an orientation when a view controller is pushed. Did you read my answer in the link? It will only work on modally presented view controllers. – Léo Natan Mar 31 '14 at 20:20