objective-c - upSideDown iPhone 方向在 iOS 6 中不起作用?

标签 objective-c ios6 xcode4.5 uiinterfaceorientation uideviceorientation

希望你一切都好,尽力而为。

我在 iOS 6upSideDown Orientation 中遇到问题,虽然我认为我做的一切都很完美,但我不知道为什么它不起作用对我来说。我正在与您分享我的问题,以便获得任何解决方案。

到目前为止我做了什么:

a) 在 xcode 项目摘要选项卡中,我启用了所有 4 个方向。

b) 我在我所有的 Controller 类中添加了一段代码(写在下面)。

-(BOOL)shouldAutorotate
{
    return YES;
}
-(NSInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

upSideDown 方向 仍然不起作用

感谢期待。

最佳答案

我找到了它的解决方案。

我们需要制作一个单独的 UINavigation Controller 类。在.m文件中添加以下方法

// Deprecated in iOS6, still needed for iOS5 support.
// ---

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    //    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    return YES;
}

// iOS6 support
// ---
- (BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskAll;
}

现在将这个新创建的类分配给 Storyboard中的Navigation Controller。还要在“项目 -> build设置 -> 编译源”中添加此类的 .m 文件。运行该项目,它将支持并执行所有方向,包括 upSideDown

希望对大家有所帮助。

问候

关于objective-c - upSideDown iPhone 方向在 iOS 6 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13720907/

相关文章:

ios - 使用 iOS6 之前的 ARC 时是否仍然需要 'dealloc' 和 'viewDidUnload' 方法?

ios - 如何使用 iOS 6 sdk 为 iPhone 4s 或 iPhone 4 制作 View Controller ?

iOS 6.1 与 willTransitionToState 的行为不同

ios - 为什么大多数指令在向项目添加库时显示 "uncheck copy items into the destination folder"?

ios - 如何以编程方式执行 Unwind segue?

objective-c - ALAsset 上的 defaultRepresentation fullScreenImage 不返回全屏图像

iphone - 目标文件格式无法识别、无效或不适合 xcode

iphone - 如何向plist的子键添加子项/级别(多级别)?

ios - 如何以编程方式在 UITableViewCell 上启用编辑模式?

objective-c - 获取枚举项的总数