ios – 以模式视图保持父视图的方向呈现不同的方向

ios – 以模式视图保持父视图的方向呈现不同的方向,第1张

概述所以我正在开发一个只支持横向模式的iPad应用程序,除了在一个模态视图控制器上.我遇到的问题是,一旦我提出模态视图,并将方向改变为纵向,然后关闭视图,父视图(只应支持横向)是纵向模式,直到我旋转设备,然后再回到景观和住宿方式.我一直在努力弄清楚如何让父母看到原始的方向,但是却无法找到解决方案. 我的应用程序委托中有以下代码,仅允许在单个模态视图(GalleryPhotoViewer)上进行方向更改 所以我正在开发一个只支持横向模式的iPad应用程序,除了在一个模态视图控制器上.我遇到的问题是,一旦我提出模态视图,并将方向改变为纵向,然后关闭视图,父视图(只应支持横向)是纵向模式,直到我旋转设备,然后再回到景观和住宿方式.我一直在努力弄清楚如何让父母看到原始的方向,但是却无法找到解决方案.

我的应用程序委托中有以下代码,仅允许在单个模态视图(galleryPhotoVIEwer)上进行方向更改:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrIEntationsForWindow:(UIWindow *)window{NSUInteger orIEntations = UIInterfaceOrIEntationMaskAllButUpsIDeDown;    if(self.window.rootVIEwController){        UIVIEwController *presentedVIEwController = [[(UINavigationController *)self.window.rootVIEwController vIEwControllers] lastObject];        //Support Portrait mode only on PhotovIEwer        if ([[presentedVIEwController presentedVIEwController] isKindOfClass:galleryPhotoVIEwController.class] ) {            orIEntations = UIInterfaceOrIEntationMaskAll;        }else{            orIEntations = [presentedVIEwController supportedInterfaceOrIEntations];        }    }    return orIEntations;}

从父类(PhotosVIEwController)我打电话:

galleryPhotoVIEwController *gpVIEw = [galleryPhotoVIEwController new];[self presentVIEwController:gpVIEw animated:YES completion:nil];

还有在我的父母(和其他意见)我有以下代码不允许肖像模式:

- (NSUInteger)supportedInterfaceOrIEntations{    return UIInterfaceOrIEntationMaskLandscapeleft | UIInterfaceOrIEntationMaskLandscapeRight;}- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation{    if(interfaceOrIEntation == UIInterfaceOrIEntationPortrait) {       return YES;    } else {        return NO;    }}

关于我如何保持我父母观点的方向的任何想法?我正在考虑可能只是以编程方式在vIEwWillAppear方法中改变方向,一旦模态被关闭,然后我不知道以前的方向是什么,更不用说我还没有找到代码来做这个不管ios6.

编辑/解决方案:所以我找到一个解决方案,我最后做的是离开应用程序:supportedInterfaceOrIEntationsForWindow:代码,只是将UINavigation子类添加到父视图,呈现模态视图,一切按预期工作,父级保留原来而模态能够自由地改变.

在我的父母:

//To make sure that this vIEw remains in Landscape@implementation UINavigationController (Rotation_IOS6)-(BOol)shouldautorotate{    return [[self.vIEwControllers lastObject] shouldautorotate];}-(NSUInteger)supportedInterfaceOrIEntations{    return [[self.vIEwControllers lastObject] supportedInterfaceOrIEntations];}@end

感谢@matt的建议.

解决方法 我认为问题是你使用的应用程序:supportedInterfaceOrIEntationsForWindow :.相反,摆脱这一点,并从UINavigationController子类开始,并将根视图控制器的类作为您的导航界面.然后:

>在UINavigationController子类中,从supportedInterfaceOrIEntations返回UIInterfaceOrIEntationMaskLandscape.>在显示(模态)视图控制器中,从supportedInterfaceOrIEntations返回UIInterfaceOrIEntationMaskAll.

总结

以上是内存溢出为你收集整理的ios – 以模式视图保持父视图的方向呈现不同的方向全部内容,希望文章能够帮你解决ios – 以模式视图保持父视图的方向呈现不同的方向所遇到的程序开发问题。

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

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

原文地址:https://54852.com/web/1111769.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存