iphone - 为什么这个方向代码不起作用?

标签 iphone objective-c ios orientation

我有一个简单的 UIWebView 嵌套在 ViewController 中,它以模态方式呈现在导航 Controller 之外。

结构如下:TableViewController -> TableViewController -> Modal(WebView呈现)-> Modal(选项,通过手势呈现,页面 curl )

所有 View 都处理所有方向,除了上面有 WebView 的那个,它是通过配置来处理它的方向。

带有 Web View 的 Controller 具有以下方向代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    BOOL orientationSwitch = NO;

    if([self.webApp.orientationLandscape boolValue] &&
       UIInterfaceOrientationIsLandscape(interfaceOrientation))
        orientationSwitch = YES;

    if([self.webApp.orientationPortrait boolValue] &&
       UIInterfaceOrientationIsPortrait(interfaceOrientation))
        orientationSwitch = YES;

    return orientationSwitch;
}

现在的目的是您可以设置一些选项来决定 View 是否应该对方向变化使用react。在大多数情况下它可以工作,但是我有一个模态弹出窗口,您可以在其中选择关闭包含 Web View 的模态。一旦发生这种情况,似乎整个应用程序的方向都被锁定了。所有其他 View 随后不响应任何形式的旋转。

有任何想法吗?

谢谢

最佳答案

这里有一些东西可以尝试。向 UIDevice 注册 UIDeviceOrientationDidChangeNotification 并告诉它开始生成通知。当有通知进来时,调用 UIViewController 类方法attemptRotationToDeviceOrientation (仅限 iOS 5)。

此外,阅读此技术说明可能会有所帮助,因为您可能在这里做错了:https://developer.apple.com/library/ios/#qa/qa1688/_index.html

关于iphone - 为什么这个方向代码不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9450687/

相关文章:

iphone - Xcode - 未找到 SenTestingKit

ios - 在我的应用程序中访问 iCloud 联系人时导致 iOS 崩溃

ios - NSDictionary objectForKey : string issue

ios7 UITableView 高度,已更改但返回默认值

iphone - 当必需的输入参数为 nil 时在 objective-c 方法中抛出异常?

iphone - 如何在iPhone中集成Webview?

iOS 模拟器不显示 Xcode 6.3 的内容

objective-c - Obj-C/Cocos2d内存问题,调用属性时exc_bad_access

objective-c - 是否可以对比 int 所能容纳的更多的值进行位掩码?

ios - 检查 GMSPolygon 是否在其他 GMSPolygon 内部