【问题标题】:How to add .xib file for iPad in an application that was previously built for iPhone?如何在之前为 iPhone 构建的应用程序中为 iPad 添加 .xib 文件?
【发布时间】:2014-03-03 03:32:50
【问题描述】:

我有一个适用于 iPhone 的应用程序。起初我们不打算为 iPad 发布它。但现在我们希望它可用于 iPad。我已经对此进行了足够多的搜索,但没有找到任何为 iPad 添加 .xib 的好方法。

我知道还有其他方法可以更改它以支持 iPad。在 Xcode 中,我的项目 Targeted Device Family 是 iPhone/iPad。该应用程序现在在 iPad 上运行,但我想为每个视图添加不同的 iPad .xib。如何为 iPad 添加不同的 .xib?

【问题讨论】:

    标签: ios iphone objective-c ipad xcode5


    【解决方案1】:

    这里有几个选项。

    1.) 使用自动布局来尝试使用 .xib 文件在 iPad 上正确布局/空间。

    2.) 专门为 iPad 创建新的 .xib 文件,每次实例化视图控制器时,根据设备类型加载正确的 xib 文件

    ViewController *vc;
    if (iPhone)
    {
       vc = [[ViewController alloc] initWithNibName:@"iPhoneNIB" bundle:nil];
    }
    else
    {
       vc = [[ViewController alloc] initWithNibName:@"iPadNIB" bundle:nil];
    }
    

    【讨论】:

      猜你喜欢
      • 2012-03-24
      • 2011-03-14
      • 2011-04-07
      • 2014-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-02
      相关资源
      最近更新 更多