开发者

Only direct subviews of the MainWindow view gets orientation set by iOS?

Whenever my app is rotated, only the viewController of which I've added his view as a subview to the mainwindow gets his interfaceOrientation property updated, the rest remains ignorant of the fact the device has been rotated.

Is it my responsibilty to notify other objects of the change, and if so, what's a nice way to do it?

I've looked into setting interfaceOrientation of my children-viewcontrollers but that's开发者_开发百科 readonly.

Thanks in advance,


I found that calling

willRotateToInterfaceOrientation

and/or

didRotateFromInterfaceOrientation

of the view controller you are going to show worked for me. In my case I was using a Navigation Controller so it was easy to keep track of what was going to be shown to the user next. Below is some code from my project.

- (void)navigationController:(UINavigationController *)navigationController 
         didShowViewController:(UIViewController *)viewController 
         animated:(BOOL)animated {
    [viewController willRotateToInterfaceOrientation:
        [self interfaceOrientation] duration:0];    
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜