5
votes

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 !!

1
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
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!' It crashediProgrammer
My bad. It accepts an UIInterfaceOrientation and not a Mask. Btw, deleting this method works! Whats the use anyways?mayuur
let me try without this methodiProgrammer
oh yes it is working without that method. I thought we need to implement all methods. please give your answer belowiProgrammer

1 Answers

6
votes

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.