我的 View 结构如下。
HomeView(Support only portrait mode)
|
|
V
View1(Support all orientation)
|
|
V
View2(Support all orientation)
问题:
当我coming back from View2(Landscape mode)
至HomeView
通过调用 popToRootViewController
方法,它没有调用 supportedInterfaceOrientationsForWindow
App_Delegate方法并显示
首页查看 landscape mode
。
图片:
注意:
当我通过调用 popToRootViewController 方法从 View1(横向模式)返回到 HomeView 时,不会发生同样的事情
它将调用supportedInterfaceOrientationsForWindow并且一切都很好。
如果我在 iOS7 中使用 XCode6 运行应用程序,一切都很好。
I read below question but it did not help me
.
How to maintain presenting view controller's orientation when dismissing modal view controller?
在上面的链接中matt
说iOS8 stop support for friezing orientation
,但我在apple document
中没有找到它
如果您有的话reference link
请分享有关此更改的信息。
问题:
1] 为什么委托(delegate)方法supportedInterfaceOrientationsForWindow没有调用。
2] 是否有可能有一个 View 支持单一方向,而所有其他 View 将支持所有方向。
谢谢
最佳答案
我解决了这个问题并发布了答案,因为它可能会对某些人有所帮助
问题:
我在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;
}
但是 delegate
方法 supportedInterfaceOrientationsForWindow
未调用
当堆栈中存在超过两个 View Cotnrollers
时使用popToRootViewControllerAnimated
方法。
解决方案:
Step1:创建导航 Controller 的子类。
Step2:重写popToRootViewControllerAnimated方法并编写如下代码 //覆盖父类(super class)方法 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];
}
}
请免费填写任何意见并提出任何问题。
关于iphone - 支持多界面,但主屏幕只有单一界面,在 iOS8 + iPhone 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25769068/