加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

支持多接口但在主屏幕中具有单一界面不适用于iOS8 iPhone

发布时间:2020-12-14 00:51:38 所属栏目:百科 来源:网络整理
导读:我有如下的视图结构. HomeView(Support only portrait mode) | | VView1(Support all orientation) | | VView2(Support all orientation) 问题: 当我通过调用popToRootViewController方法从View2(横向模式)返回到HomeView时,它没有调用App_Delegate的suppor
我有如下的视图结构.
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];
    }
}

如有任何意见,请随意填写并提出任何问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读