【问题标题】:Use current orientation on push view controller在推送视图控制器上使用当前方向
【发布时间】:2013-12-17 09:11:29
【问题描述】:

我有两个视图控制器,foo 仅是纵向的,bar 是纵向+横向的。 当我将bar 推到foo 上时,foo 总是以纵向方向开始。用户需要在推送后倾斜手机以使操作系统检测到新的方向。我更喜欢foo 从加载的那一刻起就处于横向状态,如果手机在被推动的那一刻就处于横向状态。

这如何在 iOS6 和 7 上实现?

【问题讨论】:

    标签: ios ios7 autorotate


    【解决方案1】:

    我会添加此代码

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Adapt the orientation with your need
        return (interfaceOrientation != UIInterfaceOrientationPortrait &&
                interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    }
    
    - (BOOL)shouldAutorotate {
        UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
    
        if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
           return YES;
        else
           return NO;
    }
    
    -(NSUInteger)supportedInterfaceOrientations{
        return UIInterfaceOrientationMaskLandscapeLeft;
    }
    

    【讨论】:

    • 如果我理解正确,您希望同时支持横向和纵向,但是如果手机处于横向模式,您还希望视图显示为横向吗?如果是这样,您是否尝试设置一些条件?我编辑我的答案
    • 我看到这个问题还是悬而未决,你找到解决办法了吗?
    猜你喜欢
    • 2015-07-23
    • 2016-07-29
    • 1970-01-01
    • 2012-07-28
    • 2013-05-12
    • 2020-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多