【问题标题】:Autorotation iOS6 [duplicate]自动旋转iOS6 [重复]
【发布时间】:2013-01-05 16:03:27
【问题描述】:

可能重复:
How to make app fully working correctly for autorotation in iOS 6?

在 iOS6 中遇到自动旋转问题。我在 App Delegate 中添加了这个:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return (UIInterfaceOrientationMaskAll);
}

并在视图控制器中添加了这个:

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskPortrait);
}

我仍然无法让它只是纵向而不是横向!非常感谢您的帮助。

【问题讨论】:

  • 我已经发布了一个答案 Ryan...
  • 类似,但我有更多代码,现在真的还有更多。

标签: objective-c ios autorotate


【解决方案1】:

您无需在 App Delegate 对象中设置界面方向。在 Project Navigator 中选择您的项目文件。然后选择目标并选择 Summery。您可以在此处选择支持的接口方向。这适用于整个项目。

【讨论】:

  • 我需要它在不同的视图中有所不同。
  • @RyanGittings 这是一种反模式,在 iOS 6 中不鼓励使用。
  • 嗯,应用程序的大部分是数据,我有一个视图并加载一个图像,(FGallery),我想让横向能够查看图片横向...跨度>
  • 您不必返回 UIInterfaceOrientationMaskAll 因为它是 iPad 的默认值。 iPhone 的默认设置是 UIInterfaceOrientationMaskAllButUpsideDown。你支持哪种设备? iPad 还是 iPhone?
  • 它是一个 iPhone 应用程序...已从应用程序委托中删除。我需要在 ViewController 中放入什么?我已取消选中目标中所有支持的界面方向...
【解决方案2】:

仅将其粘贴到 ViewController:

- (NSUInteger)supportedInterfaceOrientations
{
     return (UIInterfaceOrientationMaskPortrait);
}

删除shouldAutorotateapplication:supportedInterfaceOrientationsForWindow:

【讨论】:

  • 完成了这个,没用。我是否在应用设置的目标中选择任何内容,支持的界面方向按钮?
  • 是的,您应该选择您希望在您的应用中使用的方向。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多