【问题标题】:UI ScrollView Hiding in iPad Landscape modeiPad横向模式下的UI ScrollView隐藏
【发布时间】:2023-04-02 19:45:02
【问题描述】:

我在其中添加了一个 UIScrollView 和 2 个 UIImageView。它在肖像模式下显示得很好。但它以横向模式隐藏它。我从 xcode n 模拟器运行并实现了方法 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation。

我是 iPad 编程的新手,但被卡住了。感谢任何帮助。

【问题讨论】:

    标签: iphone ipad


    【解决方案1】:
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    
        if(UIInterfaceOrientationIsLandscape(interfaceOrientation))
        {
            [self.view insertSubview:scrollView aboveSubview:imageView];
        }
        else
        {
    
            [self.view insertSubview:imageView aboveSubview:scrollView];
        }
    
        return YES;
    }
    

    【讨论】:

      【解决方案2】:

      问题似乎是您添加的这些视图的自动调整大小。如果您从 Interface Builder 创建它们,请转到右侧面板上的第五个选项卡并选择一个视图,您可以在其中设置视图以在父视图更改其大小时调整其大小和位置(旋转设备时会发生这种情况)。如果您从代码创建这些视图,您应该设置自动调整掩码(使用方法 setAutoresizingMask:),您可以添加多个值以获得所需的效果。

      希望这会有所帮助!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-01-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多