本文介绍了支持多接口但在主屏幕中具有单一界面,在iOS8 + iPhone中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有如下的视图结构。I have view structure like below.HomeView(Support only portrait mode) | | VView1(Support all orientation) | | VView2(Support all orientation) 问题: 当我从View2(横向模式)返回 HomeView 时调用 popToRootViewController 方法,它没有调用 supportedInterfaceOrientationsForWindow App_Delegate的方法并在横向模式中显示 HomeView 。Problem :When i am coming back from View2(Landscape mode) to HomeView by calling popToRootViewController method,It did not call supportedInterfaceOrientationsForWindow method of App_Delegate and displayHomeView in landscape mode. 图片:Image: 注意: 当我从View1(横向模式)回到HomeView时,同样的事情不会发生通过调用popToRootViewController方法,它将调用supportedInterfaceOrientationsForWindow并且一切正常。 如果我在iOS7中使用XCode6运行应用程序,那么一切都很好。Note :Same thing not happens when i came back from View1(Landscape mode) to HomeView by calling popToRootViewController methodit will call supportedInterfaceOrientationsForWindow and all works great.If I run app using XCode6 in iOS7 all works great. 我在下面阅读了一些问题,但它没有帮助我。 如何保持呈现在解雇模态视图控制器时查看控制器的方向?在上面的链接 matt 表示 iOS8停止支持带有方向性的 ,但我没有在苹果文档中找到它 如果您有任何关于此更改的参考链接,请分享。In above link matt said that iOS8 stop support for friezing orientation, but I did not find it in apple documentif you have any reference link about this change please share. 问题: 1]为什么委托方法supportedInterfaceOrientationsForWindow没有调用。 2]是否可以让一个视图支持单向,而所有其他视图都支持所有方向。 谢谢Question :1] Why delegate method supportedInterfaceOrientationsForWindow is not calling.2] Is it possible to have one view with support single orientation and all other will support all orientation.Thanks推荐答案 我解决了这个问题并将答案发布为它可以帮助一个人 问题: 我在supportedInterfaceOrientationsForWindow中有以下代码。Problem :I have below code in supportedInterfaceOrientationsForWindow.- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ // Suport only portrait mode for home screen if([self.navigationController.topViewController isKindOfClass:[ViewHome class]]) { return UIInterfaceOrientationMaskPortrait; } return UIInterfaceOrientationMaskAll;}但是委托方法 supportedInterfaceOrientationsForWindow 当使用 popToRootViewControllerAnimated 方法时,如果有多出两个视图,则不会调用 Cotnrollers 存在于堆栈中。 解决方案: 步骤1:创建导航控制器的子类。But delegate method supportedInterfaceOrientationsForWindow not calledwhen use popToRootViewControllerAnimated method when there ismore then two view Cotnrollersexists in stack.Solution :Step1: Create sub class of Navigation controller. Step2:覆盖方法popToRootViewControllerAnimated并编写如下代码 //覆盖超类方法popToRootViewControllerAnimated。Step2: Override method popToRootViewControllerAnimated and write code as below// Overwrite super class method popToRootViewControllerAnimated.-(NSArray*)popToRootViewControllerAnimated:(BOOL)animated{ // Only for iOS8 and above if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) { // Array which will contaimn all poped view controllers object. NSMutableArray *popedControllersArray = [[NSMutableArray alloc] init]; // Tmp created controllers object NSArray *controllers; // Hold first view cotnrollers. UIViewController *firstViewController = [self.viewControllers objectAtIndex:1]; // Pop to first view controllers with no animation. controllers = [super popToViewController:firstViewController animated:NO]; // Add poped view cotnrollers objects to the array. [popedControllersArray addObjectsFromArray:controllers]; // Pop to root view controller with animation [super popViewControllerAnimated:YES]; // Add first view controller object as it is poped by above line. [popedControllersArray addObject:firstViewController]; // return poped view controllers object. return popedControllersArray; } else { // Called super view popToRootViewControllerAnimated method and return popped // view controllers array. return [super popToRootViewControllerAnimated:animated]; }}如有任何意见,请随意填写并提出任何问题。Please fill free for any comments and ask for any questions. 这篇关于支持多接口但在主屏幕中具有单一界面,在iOS8 + iPhone中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-14 13:21