Rotation behaving differently on iOS6

后端 未结 12 2201
野的像风
野的像风 2020-11-30 06:00

I did an App which is tab-based. Nothing needs to be on landscape mode but a couple of views. It worked OK on iOS5 and I was pretty happy with the result. However with iOS6

12条回答
  •  执念已碎
    2020-11-30 06:52

    There are a few things you may need to handle to get this working since with iOS6 the structure of autorotate has changed. The structure of how autorotate is determined is now reversed. It used to be that an individual view controller can control the autorotate with its decision but now the "shouldAutorotate" is determined by the highest parent in the navigation which in your case is the tabBar.

    1. You need to make sure your window has a rootViewController set and not just added as a subview.
    2. You may need to subclass your tabBarController to implement both "supportedInterfaceOrientations" and "shouldAutorotate".
    3. If there are any viewControllers that need to behave differently then you will need to have your tabBarController consult with them for the answer on whether they should autorotate.

    for example:

    - (BOOL)shouldAutorotate
    {
        return self.selectedViewController.shouldAutorotate;
    }
    

    and in your view controller you would implement shouldAutorotate and make the decision there.

提交回复
热议问题