1
votes

I am using UINavigationController in my application and my first controller called A and it is strict to portrite only and there is a button in my A controller.Once I click on the button I am creating instance to the another view controller called B. After creating the instance for B I am presenting modally using below method

[self presentViewController:BInstance animated:YES completion:^{
            NSLog(@"completed");
        }];

My B controller can able will support all the orientations, this is expected, till the ios5.1 and earlier versions. Now I am trying to run my project on the ios6 using Xcode4.5 it is not getting rotated I am looking forward to solve the issue I found some of the blogs about shouldAutorotateToInterfaceOrientation: method got deprecated from the latest ios6. I used alternative also

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

But still there is not much expected results.

Question: What makes my B controller will work for all orientations even my Parent A works only for portrite.

Thanks In advance All your suggestions/advice useful on this.

1

1 Answers

5
votes

First of all, in AppDelegate, write this. THIS IS VERY IMP

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
     return (UIInterfaceOrientationMaskAll);
}

Then, For UIViewControllers, in which you need only PORTRAIT mode, write these functions

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskPortrait);
}

For UIViewControllers, which require LANDSCAPE too, change masking to All.

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskAllButUpsideDown);
    //OR return (UIInterfaceOrientationMaskAll);
}

Now, if you want to do some changes when Orientation changes, then use this function.

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{

}