5

I am using New orientation methods of ios 6 and it is working fine. My view is presenting in portrait mode and when I presentviewcotrnoller and rotate it to landscape , dismiss that viewcontroller it reverts orientations. means it should remain in landscape but it becomes to portrait. Here is my code.

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;

}

// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
    return YES;
}

// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationMaskPortrait;
}

I think it is happening because of preferredInterfaceOrientationForPresentation method ,but not getting the solution for this.Please Help !

Thanks !!

Charan
  • 4,940
  • 3
  • 26
  • 43
iProgrammer
  • 3,099
  • 3
  • 33
  • 59
  • What is the exact problem btw? You have set Portrait only for preferredInterfaceOrientation. Hence, the controller should always be presented in Portrait mode only I guess. Try UIInterfaceOrientationMaskAll and check what happens. – mayuur Oct 06 '12 at 10:20
  • Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!' It crashed – iProgrammer Oct 06 '12 at 10:23
  • 2
    My bad. It accepts an UIInterfaceOrientation and not a Mask. Btw, deleting this method works! Whats the use anyways? – mayuur Oct 06 '12 at 10:30
  • let me try without this method – iProgrammer Oct 06 '12 at 10:33
  • oh yes it is working without that method. I thought we need to implement all methods. please give your answer below – iProgrammer Oct 06 '12 at 10:42
  • thx for the commnent of "deleting this method works!". That just saved my life! – Emre Akman Nov 22 '12 at 17:34
  • How to support multiple orientations in one app in ios6: http://stackoverflow.com/a/13881884/1303639 – Hox Dec 14 '12 at 15:50

1 Answers1

6

If you want all the interfaceOrientations supported at the start, do not write the preferredInterfaceOrientationForPresentation method, as it would take just that preferred Interface orientation all the time.

mayuur
  • 4,736
  • 4
  • 30
  • 65