iOS 6 auto rotate confusion

前端 未结 6 765
萌比男神i
萌比男神i 2020-12-29 17:08

I have my entire interface in one Storyboard. How can I make most of the ViewControllers only support a portrait orientation while only a couple supporting all orientations.

6条回答
  •  一向
    一向 (楼主)
    2020-12-29 17:45

    If you are using a native rootViewController, you have to extend it to support iOS5 gracefully. This is said in the above mentioned WWDC video.

    Basically, if you are using a UINavigationViewController, extend it and override its - (NSUInteger)supportedInterfaceOrientations method. In there, look into your children (you can just query the older methods for interface orientation you have) and determine what should be supported and return the correct value.

    The reason you need to do this to be backward compatible is 2 things: - they've deprecated the old way of rotating stuff - only rootViewController ever gets the rotation call. The parent should decide for its children what orientation it needs to be in. All these changes are inline with the new AutoLayout stuff.

    After you extend your nav controller, go to your storyboard -> select the root controller (navigation controller in this case) -> set the class to your newly written class.

    HTH

提交回复
热议问题