Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 6:父模式';旋转后忽略s modalPresentationStyle_Ios_Ipad_Rotation_Modal Dialog - Fatal编程技术网

iOS 6:父模式';旋转后忽略s modalPresentationStyle

iOS 6:父模式';旋转后忽略s modalPresentationStyle,ios,ipad,rotation,modal-dialog,Ios,Ipad,Rotation,Modal Dialog,在装有iOS6的iPad上,我们遇到了这样一个错误:模式视图控制器将扩展到全屏,即使它被告知要这样做 使用“表格”展示风格。但是,只有当有两个情态动词时才会发生这种情况,一个是父情态动词,另一个是子情态动词 这就是第一个模态的创建和呈现方式: UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelea

在装有iOS6的iPad上,我们遇到了这样一个错误:模式视图控制器将扩展到全屏,即使它被告知要这样做 使用“表格”展示风格。但是,只有当有两个情态动词时才会发生这种情况,一个是父情态动词,另一个是子情态动词

这就是第一个模态的创建和呈现方式:

UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[parentController presentModalViewController:navigationController animated:YES];
// parentController is my application's root controller
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[parentController presentModalViewController:navigationController animated:YES];
// parentController is the navigationController from above
以下是创建和显示子模态的方式:

UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[parentController presentModalViewController:navigationController animated:YES];
// parentController is my application's root controller
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[parentController presentModalViewController:navigationController animated:YES];
// parentController is the navigationController from above
因此,当从横向旋转到纵向时,父模式将扩展到全屏,即使我们旋转回横向,也将保持这种方式

当父模态完全独立(无子模态)时,它将按预期工作,即保持表单样式

请注意,这只发生在iOS6上(设备和模拟器),而不会发生在IOS5上(模拟器和测试人员报告的工作)

到目前为止,我已经尝试了以下方法,但没有成功:

  • wantsFullScreenLayout
    设置为
    NO
  • 通过覆盖wantsFullScreenLayout,强制其始终返回
    NO
  • 确保导航控制器中的“我的控制器”也指定了
    UIModalPresentationFormSheet
  • 实施演示文稿的首选界面定位
  • 升级至iOS 6.0.1
谢谢


更新: 因此,我修改了Apple开发者论坛()的响应,使其能够与多个嵌套模式一起工作

- (BOOL) needNestedModalHack {
    return [UIDevice currentDevice].systemVersion.floatValue >= 6;
}

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                          duration:(NSTimeInterval)duration {

    // We are the top modal, make to sure that parent modals use our size
    if (self.needNestedModalHack && self.presentedViewController == nil && self.presentingViewController) {
        for (UIViewController* parent = self.presentingViewController;
             parent.presentingViewController;
             parent = parent.presentingViewController) {
            parent.view.superview.frame = parent.presentedViewController.view.superview.frame;
        }
    }

    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                 duration:(NSTimeInterval)duration {
    // We are the top modal, make to sure that parent modals are hidden during transition
    if (self.needNestedModalHack && self.presentedViewController == nil && self.presentingViewController) {
        for (UIViewController* parent = self.presentingViewController;
             parent.presentingViewController;
             parent = parent.presentingViewController) {
            parent.view.superview.hidden = YES;
        }
    }

    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    // We are the top modal, make to sure that parent modals are shown after animation
    if (self.needNestedModalHack && self.presentedViewController == nil && self.presentingViewController) {
        for (UIViewController* parent = self.presentingViewController;
             parent.presentingViewController;
             parent = parent.presentingViewController) {
            parent.view.superview.hidden = NO;
        }
    }

    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}

我在这里看到两个问题

1) 在iOS 6中,不推荐使用方法
presentModalViewController:animated:
,请尝试使用
presentViewController:animated:completion:
(尽管这可能没有帮助,但您仍可能希望这样做)


2) 在iOS 6中,容器控制器(如
UINavigationController
)似乎不会将自动旋转消息重新发送给其子代。尝试子类化
UINavigationController
,并重新定义要发送给所有子级的相应自动旋转方法。这可能会有所帮助。

不确定这是否应该被视为一个bug,我很好奇iOS 7会带来什么,但目前解决此问题的方法是将子viewController的modalPresentationStyle设置为UIModalPresentationCurrentContext

Set modalPresentationStyle = UIModalPresentationCurrentContext
这使得子级仍然以表单的形式呈现,但阻止父级在旋转时调整大小为全屏


Dirk

您需要在主视图之后实例化导航控制器。 这样您就可以在每个视图中管理旋转


如果您的AppDelegate RootViewController是一个导航控制器,您将无法使用本机函数管理轮换。

有人将我指向apple开发者论坛,我发现:呈现多个模态显然打破了apple所说的您应该做事情的方式。如果你最终做了这样违背苹果公司建议的事情,那么你就可以预料到这样的问题。还认为你可能有一个非常糟糕的设计。如果您想像这样显示多个ViewController,您应该在单一模式演示中使用包容或navigationController。当iOS 6.3中再次出现这种情况时,您将怎么做?@Ade:本文档提到可以链接模态视图控制器:感谢您向我指出这一点,值得一提的是,我以为您试图从单个viewController父级(而非链接)呈现多个模态viewController。我个人一直在导航控制器中使用ViewController。我觉得自己像个傻瓜;)1.同意。在我写这篇文章的时候,我们仍然支持4.3。我在测试时没有遇到问题,而且离现场很远。我确实经常使用导航控制器。也许我的内容控制器足够通用,不会出现任何问题…

我想我们会看到iOS7,因为苹果似乎改变了每个主要版本的轮换回调工作方式…;-)这解决了我的问题。我从另一页纸创建了一页纸。调整了大小后,父页面占据了我的整个屏幕。