简体   繁体   English

在iPhone OS 3.0上更改方向时管理子视图

[英]Managing subview when orientation change on iPhone OS 3.0

I am experiencing difficulties managing my view controller rotation. 我在管理视图控制器旋转时遇到困难。 Here is my app structure : 这是我的应用程序结构:

[Window]
---[addSubview:MainViewController.view]

My MainViewController's view contains an UIImageView which I need to rotate, this is my app background. 我的MainViewController的视图包含一个需要旋转的UIImageView,这是我的应用程序背景。

In my AppDelegate and MainController I overrided shouldAutorotateToInterfaceOrientation to return YES, but when I rotate my device nothing change. 在我的AppDelegate和MainController中,我重写了shouldAutorotateToInterfaceOrientation以返回YES,但是当我旋转设备时,没有任何变化。 Even the status bar. 甚至状态栏。

Should I manually apply transformation to my views when I receive UIDeviceOrientationDidChangeNotification ? 收到UIDeviceOrientationDidChangeNotification时,是否应该对视图手动应用转换?

In IB I set resize subviews to YES in mainViewController.view. 在IB中,我在mainViewController.view中将子视图的调整大小设置为YES。

So I am a little bit lost... 所以我有点迷路了...

Thanks for your help. 谢谢你的帮助。

thierry 蒂埃里

Actually, you should override shouldAutorotateToInterfaceOrientation: — notice the colon, it's significant in ObjC — and only in the current view controller. 实际上,您应该重写shouldAutorotateToInterfaceOrientation: —注意冒号,它在ObjC中很重要—仅在当前视图控制器中。

@implementation MainViewController
...
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM