我有如下所示的视图结构。
HomeView(Support only portrait mode)
|
|
V
View1(Support all orientation)
|
|
V
View2(Support all orientation)
问题 :
当我coming back from View2(Landscape mode)
to HomeView
通过致电popToRootViewController
方法,没有调用supportedInterfaceOrientationsForWindow
的方法应用程序_委托并显示首页查看于landscape mode
.
Image:
Note :
当我通过调用 popToRootViewController 方法从 View1(横向模式)返回到 HomeView 时,不会发生同样的事情
它将调用supportedInterfaceOrientationsForWindow并且一切都很好。
如果我在 iOS 7 中使用 XCode 6 运行应用程序,一切都很好。
I read below question but it did not help me
.
关闭模态视图控制器时如何保持呈现视图控制器的方向?
在上面的链接中matt
说iOS8 stop support for friezing orientation
,但我没有找到它apple document
如果你有任何reference link
关于此更改,请分享。
问题 :
1]为什么委托方法supportedInterfaceOrientationsForWindow没有调用。
2] 是否有可能有一个视图支持单一方向,而所有其他视图将支持所有方向。
Thanks
我解决它并发布答案,因为它可能会对某人有所帮助
问题 :
我在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;
}
But delegate
method supportedInterfaceOrientationsForWindow
没有被调用
使用时popToRootViewControllerAnimated
方法当有more then two view Cotnrollers
存在于堆栈中。
解决方案 :
步骤1:创建导航控制器的子类。
步骤2:重写方法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];
}
}
请免费填写任何意见并提出任何问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)