HomeView(Support only portrait mode) | | V View1(Support all orientation) | | V View2(Support all orientation)
问题:
当我通过调用popToRootViewController方法从View2(横向模式)返回到HomeView时,它没有调用App_Delegate的supportedInterfaceOrientationsForWindow方法并显示
HomeView在横向模式下.
图片:
注意 :
当我通过调用popToRootViewController方法从View1(横向模式)返回到HomeView时,同样的事情不会发生
它将调用supportedInterfaceOrientationsForWindow并且所有工作都很棒.
如果我在iOS7中使用XCode6运行app,一切都很棒.
我在下面阅读了这个问题,但它对我没有帮助.
How to maintain presenting view controller’s orientation when dismissing modal view controller?
在上面的链接亚光表示iOS8停止支持friezing方向,但我没有在苹果文档中找到它
如果您有关于此更改的任何参考链接,请分享.
题 :
1]为什么委托方法supportedInterfaceOrientationsForWindow没有调用.
2]是否可以使一个视图具有支持单一方向,而所有其他视图将支持所有方向.
谢谢
问题:
我在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方法时,堆栈中有两个以上的Cotnrollersexists视图.
方案:
第1步:创建导航控制器的子类.
Step2:覆盖方法popToRootViewControllerAnimated并编写如下代码
//覆盖超类方法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]; } }
如有任何意见,请随意填写并提出任何问题.