【问题标题】:Set different constraints for iPad in portrait and landscape mode在纵向和横向模式下为 iPad 设置不同的约束
【发布时间】:2015-12-29 11:16:11
【问题描述】:

当设备处于纵向时,我在 viewController 中有 tableView 和 graphView。当我更改为横向模式时,我只想显示 graphView。我正在使用尺寸等级来做到这一点。它适用于所有 iPhone。

但对于 iPad,纵向和横向的尺寸类别是相同的(常规宽度和高度)。

我需要为纵向和横向模式设置不同的约束。如何在设备处于横向时删除 tableView。

【问题讨论】:

    标签: ios ipad storyboard autolayout size-classes


    【解决方案1】:

    此代码可能会对您有所帮助:

    - (void) handleOrientation:(UIInterfaceOrientation) orientation 
    {
    
        if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
        {
           //handle the portrait view
        }
        else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
        {
          //handle the landscape view
          //write your code for removing Table
        }
    }
    

    【讨论】:

    • 约束是通过情节提要处理的,那是什么方法呢?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 2016-09-06
    • 2017-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多