cocoa - iOS6的目标方向shouldAutorotate

标签 cocoa ios6

我想允许应该根据目标方向旋转

[[UIDevice currentDevice] orientation] 

但是,上面的代码在 shouldRotate 中使用时保持当前(旧)方向,而不是目标方向

- (BOOL) shouldAutorotate {

    return YES;
}

最佳答案

好吧,我明白了。在 shouldAutorotate 中始终返回 YES,然后执行以下操作:

- (NSUInteger)supportedInterfaceOrientations
{
    if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft) {
        // Allow if you can
    } else if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
        // Allow if you can
    }
    // so on
}

关于cocoa - iOS6的目标方向shouldAutorotate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12705348/

相关文章:

objective-c - 将 Delegate 设置为放置在 Xib 中的 NSImageView 的子类

iphone - XCode base_convert

C++ 标准库在 .mm 文件中找到,但在 .h 中找不到(Xcode 4.5 LLVM GCC 4.2)

ios - iOS5 中我的 UITableView 出现 dequeueReusableCellWithIdentifier 错误

ios - 使用 Podfile 设置组织和类前缀

cocoa - "coupled"NSWindows

ios - 如何将 objective-c 函数作为回调传递给 C 函数?

cocoa - 我的应用程序被拒绝。它访问 '/usr/lib/libpcap.A.dylib' 我该怎么做才能避免它?

ios - 限制广告跟踪和广告 sdk

ios - 我想为我的iPhone应用程序增加UITableViewStyleGrouped的边框单元格的厚度