在XCode 5中创建新的“单一视图应用程序”时,没有.xib文件

时间:2013-09-30 11:03:42

标签: xcode5

当我在xcode 5中创建一个新项目选择选项(单一视图应用程序)时,它会自动添加Main.storyboard,因为我们在之前版本的xcode中选择了.Xib文件,没有选项可供选择.Xib文件。 请有人解释一下

2 个答案:

答案 0 :(得分:20)

我的建议是:

  1. 创建一个空的应用
  2. 转到File/New/File,选择Objective-C Class
  3. 为您的班级ViewController(或您喜欢的任何内容)命名,将其设为UIViewController的子类 确保您已选中“使用xib进行用户界面”框。

  4. 打开appDelegate.h,添加

  5.   

    @class ViewController;

    介于@interface and #import和以下此属性之间:

    @property (strong, nonatomic) UIViewController *viewController;
    
    1. 打开appDelegate.m:导入ViewController
    2.   

      #import“ViewController.h”

      之前

      [self.window makeKeyAndVisible];
      

       self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
          self.window.rootViewController = self.viewController;
      

答案 1 :(得分:10)

要在xcode 5中添加XIB,请使用Empty应用程序而不是单一视图应用程序。有关集成XIB的简单方法,请参阅此question