【发布时间】:2011-06-22 15:29:18
【问题描述】:
我的应用中有两个 UIViewController。我在它们之间切换视图。一个是隐藏的,另一个不是。除了方向问题,一切都很好。在两个 UIViewController 我重写了这个方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight)||
(interfaceOrientation == UIInterfaceOrientationLandscapeLeft));
//return YES;
}
并在两个 Xib 文件中将方向设置为横向。
在 ***Delegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
.......
viewController.view.hidden=TRUE;
[self.window addSubview:viewController.view];
[self.window addSubview:menuController.view];
.....
}
如果我添加 viewController.view 第一个 viewController.view 是横向位置,它可以旋转到 LandscapeLeft 或 LandscapeRight。但是 menuController.view 仍然是纵向位置,视图根本无法旋转。
如果我先添加 menuController.view,情况正好相反。
为什么会这样?如何解决这个问题?我的应用程序快完成了。有没有什么简单的方法可以在不对我的代码进行重大更改的情况下解决这个问题。
感谢任何建议。非常感谢!
【问题讨论】:
标签: ios uiview uiviewcontroller rotation