【问题标题】:Orientatin issue in ios 6.0 and laterios 6.0 及更高版本中的方向问题
【发布时间】:2023-08-11 17:54:01
【问题描述】:

我正在开发一个应用程序,其中一个 UIViewController 中有多个 UIViews。现在的问题是它的所有 UIView 都处于横向模式,这里只有一个 UIView 是纵向的。我无法使用 shouldAutorotate 方法获得这个特定的输出。

谁能建议我解决这个问题的具体方法。

【问题讨论】:

    标签: iphone ios6 uiinterfaceorientation


    【解决方案1】:

    @pratik-bhiyani 谢谢... 但是当我需要旋转我的视图时,我已经完成了这种代码来获取特定的代码

    - (IBAction)btnClickToRedeem:(id)sender
    {
        isPortraitRqurd = TRUE;
        [self shouldAutorotate];
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    {
        if(isPortraitRqurd)
            return (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
        else
            return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    
    }
    
    -(BOOL)shouldAutorotate
    {
        return YES;
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        if(isPortraitRqurd)
            return UIInterfaceOrientationMaskPortrait;
        else
            return UIInterfaceOrientationMaskLandscape;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        if(isPortraitRqurd)
        {
            return UIInterfaceOrientationPortrait;
            isPortraitRqurd = FALSE;
        }
    
        else
            return UIInterfaceOrientationLandscapeRight;
    }
    

    【讨论】:

    • 你是否对构建设置进行了更改?
    • 是的,我已经完成了,然后也无法从横向设置纵向视图。
    • 返回是;并在构建设置中(如图所示)按 UpsideDown 按钮并使其变暗。
    • 如果您觉得我的回答有用,请接受并点赞,祝您有美好的一天:)