
我的应用程序委托中有以下代码,仅允许在单个模态视图(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 – 以模式视图保持父视图的方向呈现不同的方向所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)