我有一个只有横向景观的应用程序,甚至开始景观。这是工作中的iOS 5.x的罚款,但在iOS版6.x的
不辍努力很多很多事情后,一些比其他人更可疑的,我发现了一个解决方案,对我来说是明确的和可预测的。
我做了几件事。
- 我在IB中以横向模式保留视图。
- 我在项目设置检查两个横向模式 - 一个有四个图标有控制它
- 定向MGMT已经在iOS版6.x的改变我不得不重写一些方法,以支持不断变化的景观
这种方法适用于iOS 5.x的
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations.
return (interfaceOrientation & UIInterfaceOrientationMaskLandscape);
}
这2种方法都适用于iOS 6.x的
- (NSUInteger)supportedInterfaceOrientations
{
NSUInteger supportedOrientations = UIInterfaceOrientationMaskLandscape;
return supportedOrientations;
}
- (BOOL)shouldAutorotate
{
return YES;
}
- 但关键是要改变AppDelegate中的逻辑。我在那里的原始代码是添加一个子视图(controller.view)到窗口。这停止在iOS 6.x中工作 - 我将调用更改为window.setRootController。这是把它封好最后一步 - 它不会不进行此最终改变
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//[self.window addSubview:viewController.view];
[self.window setRootViewController:viewController];
[self.window makeKeyAndVisible];
return YES;
}
这是否有诀窍? – Nirma 2011-08-29 18:51:48
在我有机会解决问题之前,该项目因预算原因被终止。如果任何答案听起来像是我所寻找的东西,那么Epic_orange和mdizzle的答案就是使用视图转换策略。 Nirma的解决方案是每个人似乎都回应的标准票价。但是,这不适用于UINavigationController上下文中的理想结果。试试看:用三个视图设置UINav ...做第二个总是风景。由于我没有验证,因此无法接受答案,并且可能不会。这些天过于忙于ASP.NET MVC。 – NovaJoe 2011-08-30 19:19:14