开发者

How to get interfaceOrientation property set correctly in view controller hierarchy?

I have a custom view controller hierarchy. A开发者_运维知识库 sub view controller is added, to a custom parent view controller simply as a subview. The parent view controller also calls the sub view controller's -[willRotateToInterfaceOrientation:duration:] and -[didRotateFromInterfaceOrientation:] methods at the correct time.

Everything seems to work as it should, but for some reason, the interfaceOrientation property is not set correctly, it is always UIInterfaceOrientationPortrait.

How do I get the sub view controller to have the correct value in interfaceOrientation when I rotate to landscape?


I don't think you can, not using public APIs anyway. In addition the fact that you are trying to do so suggests that you are not following the recommended design for iOS apps. Consider the advice of the View Controller Programming Guide

Note: If you want to divide a view hierarchy into multiple subareas and manage each one separately, use generic controller objects (custom objects descending from NSObject) instead of view controller objects to manage each subarea. Then use a single view controller object to manage the generic controller objects.

UIViewControllers are intended to manage an entire screen worth of content. Once you violate that assumption you're going to be fighting the framework trying to get your views to behave as you expect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜