Home:ALL Converter>iOS6 Orientation

iOS6 Orientation

Ask Time:2012-09-23T01:24:50         Author:Hanpo

Json Formatter

I have a question about iOS 6 Orientation.Here is my file https://www.dropbox.com/s/f8q9tghdutge2nu/Orientations_iOS6.zip

In this sample code,I want to make the MasterViewController only has a Portrait Orientation and the DetailViewController has a Portrait Orientation,Landscape Orientation.

I know iOS 6 Orientation is controlled by top-most controller.

So I custom a UINavigationController(CustomNavigationController), set supportedInterfaceOrientations and shouldAutorotate in that class.

-(NSUInteger)supportedInterfaceOrientations{
    if([[self topViewController] isKindOfClass:[DetailViewController class]]){
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }else{
        return UIInterfaceOrientationMaskPortrait;
    }
}

-(BOOL)shouldAutorotate
{
    return YES;
}

Everything is fine except when DetailViewController at Landscape Orientation press back button,MasterViewController will show the Landscape Orientation.

Can I let MasterViewController always show Portrait Orientation and DetailViewController can has many orientation?

thanks!

Author:Hanpo,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12546057/ios6-orientation
Hanpo :

Thanks! Brennan,\nI also collect others way to do that in my blog.\nhttp://blog.hanpo.tw/2012/09/ios-60-orientation.html \n\nHere's the two others way.\n\n1.add a Category to UINavigationController\n\n @implementation UINavigationController (Rotation_IOS6)\n\n -(BOOL)shouldAutorotate\n {\n return [[self.viewControllers lastObject] shouldAutorotate];\n }\n\n -(NSUInteger)supportedInterfaceOrientations\n {\n return [[self.viewControllers lastObject] supportedInterfaceOrientations];\n }\n\n - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation\n {\n return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];\n }\n\n @end\n\n\n2.Swap Method Implementations (Made by spoletto) \n\nhttps://gist.github.com/3725118 ",
2012-10-10T08:04:05
yy