【问题标题】:Xcode 4.5: SupportedInterfaceOrientation is not workingXcode 4.5:SupportedInterfaceOrientation 不起作用
【发布时间】:2013-09-14 23:52:59
【问题描述】:

我正在使用iOS 5XCode 4.2。编码后,我支持横向和纵向。它工作正常。但是当我使用XCode 4.5iOS 6中的代码时,不支持方向。

有人知道原因吗?

【问题讨论】:

  • 你有没有使用任何设置方向的方法?你能放一些示例代码吗?
  • yes.- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return yes; }
  • 尝试使用 - (BOOL)shouldAutorotate{ return yes;}。它将调用 ios6 而不是 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOr‌​ientation 方法。
  • yes.. 在 ios6 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOr‌​ientation 不会被调用。
  • 在 iOS6 中,我接到电话 - (BOOL)shouldAutorotate{ return yes;}。对不起我的错误。

标签: objective-c ios5 ios6 xcode4.2 xcode4.5


【解决方案1】:

请检查您的项目设置(摘要)

支持的界面方向设置允许的方向

尝试使用以下代码锁定方向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown );
}

【讨论】:

  • 在 xcode 4.5 中使用来自 xcode 4.2 的代码时会发生什么。有什么问题吗?
  • 方向没有问题。
  • 检查shouldAutorotateToInterfaceOrientation:方法是否被调用。
  • 我没有接到 shouldAutorotateToInterfaceOrientation 的电话:
  • 你的应用支持什么方向
【解决方案2】:

我不知道它是否正确。但是我暂时使用了这种方法。如果它有用,你也可以使用。

您可以在Appdelegate 中编写此方法。

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
 [navigationController.topViewController shouldAutorotate];
 return UIInterfaceOrientationMaskAll;
}

您可以在viewController 中编写- (BOOL)shouldAutorotate 方法。

【讨论】:

  • 正在接听电话。我给了回报是的。仍然无法正常工作。我该怎么办?
  • 如果您希望支持所有方向,请将上述代码放入 appdelegate。你需要返回 UIInterfaceOrientationMaskAll;
猜你喜欢
  • 2012-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-23
  • 2014-03-14
  • 1970-01-01
相关资源
最近更新 更多