iOS 6:父模态的modalPresentationStyle旋转后忽略

iOS 6:父模态的modalPresentationStyle旋转后忽略,第1张

概述使用iPad iOS6,我们有一个模式视图控制器将扩展到全屏,即使它被告知这个错误 使用“表单”演示风格。但是,这只发生在有两个模态,一个父的一个和它的孩子。 所以这是如何创建和呈现第一模态: UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewControl 使用iPad iOS6,我们有一个模式视图控制器将扩展到全屏,即使它被告知这个错误
使用“表单”演示风格。但是,这只发生在有两个模态,一个父的一个和它的孩子。

所以这是如何创建和呈现第一模态:

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(设备和模拟器),并不会发生在iOS 5(模拟器,并报告由测试人员工作)。

到目前为止,我试过以下没有成功:

>将wantsFullScreenLayout设置为NO
>强制wantFullScreenLayout总是通过覆盖它返回NO
>使某些我的控制器在导航控制器内也指定UIModalPresentationFormSheet
>实现preferredInterfaceOrIEntationForPresentation
>升级到iOS 6.0.1

谢谢!

更新:
所以,我适应了苹果开发者论坛(https://devforums.apple.com/message/748486#748486)的响应,使其适用于多个嵌套模态。

- (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];}
解决方法 不知道这应该被认为是一个BUG,我很好奇iOS 7将带来,但目前的解决方法是为这个问题是为child-vIEwController设置modalPresentationStyle为UIModalPresentationCurrentContext。

Set modalPresentationStyle = UIModalPresentationCurrentContext

这使得孩子仍然beeing呈现为FormSheet,但防止父母beeing调整大小旋转时全屏。

短剑

总结

以上是内存溢出为你收集整理的iOS 6:父模态的modalPresentationStyle旋转后忽略全部内容,希望文章能够帮你解决iOS 6:父模态的modalPresentationStyle旋转后忽略所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1087577.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存