【问题标题】:Different Storyboards for iPad and iPhone not working rightiPad 和 iPhone 的不同情节提要无法正常工作
【发布时间】:2016-09-08 07:41:45
【问题描述】:

我,我有 2 个故事板:

  • storyboard_iphone
  • storyboard_ipad

我有 4 个视图控制器,当我在 iPad 上使用该应用程序时,只有 2 个视图控制器使用 storyboard_ipad。其他视图控制器采用storyboard_iphone。

在我的目标项目信息中,我有两行

  1. 主故事板文件基本名称 (iPad)=storyboard_ipad
  2. 主故事板文件基本名称 = storyboard_iphone

有什么问题?

【问题讨论】:

  • 您能否发布用于检测设备和显示特定情节提要的代码
  • 我把项目信息选项卡。我添加了一行 -> 主情节提要文件基本名称 (iPad)=storyboard_ipad

标签: iphone ipad storyboard


【解决方案1】:

您可以执行以下方法来根据设备获取故事板:

-(UIStoryboard*)getStoryBord{

    UIStoryboard *storyboard;

    if ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad))
    {
        storyboard = [UIStoryboard storyboardWithName:@"storyboard_ipad" bundle:nil];
    }
    else
    {
        storyboard = [UIStoryboard storyboardWithName:@"storyboard_iphone" bundle:nil];
    }

    return storyboard;
}

【讨论】:

    【解决方案2】:

    我强烈建议您对所有设备仅使用一个情节提要。创建通用应用并使用尺寸类以及自动布局。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-10
      • 2011-06-03
      • 2018-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-08
      相关资源
      最近更新 更多