3

I am updating my app for iOS 6 and having issues with the changes to autorotation. My app has a bunch of view controllers and all of them should only support the portrait layout except 1 which should support all 3 orientations except upside down.

If I add the application:supportedInterfaceOrientationsForWindow: method to the app delegate do I have to add conditions there to check if im displaying the one VC I want to be able to rotate?

The documentation states that if I implement supportedInterfaceOrientations on a VC it should override the app delegate method but this doesn't appear to be the case. I have an log statement in the method on the child VC and it is called once when the VC loads but its not called when I rotate the device, but the method in the app delegate is.

If I completely remove the method from the app delegate the orientation of my VC's seems to be completely dependent on my apps supported interface orientation settings. This of course seems to be due to the method supportedInterfaceOrientations being called once on creation of the VC but never when the device is rotated.

Does anyone have any ideas or suggestions? It would be much appreciated.

4

3 回答 3

13

替换 [window addSubview:viewController.view];window.rootViewController = viewController;

于 2012-09-21T06:24:03.073 回答
3

您还需要覆盖 - (BOOL) shouldAutorotate 并返回“YES”。这使得您可以使用“supportedInterfaceOrientations”声明您的 VC 支持的方向,然后在旋转时它应该调用“shouldAutorotate”。如果您有任何导航控制器或标签栏,您可能需要对它们进行子类化以在其中执行相同的操作。我自己最近也有这个问题。

于 2012-09-20T17:57:55.417 回答
0

尝试这个...

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{

    if (UIInterfaceOrientationIsLandscape(interfaceOrientation))  
    { 
        // here to  implement landscope code
    }
    else
    {  
        // here to  implement setframePortrait
    }
}
于 2012-09-26T13:34:56.990 回答