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

Akh*_*tar 12 xcode5

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

Mat*_*tti 20

我的建议是:

  1. 创建一个空的应用程序
  2. 转到File/New/File,选择Objective-C Class
  3. 命名您的类ViewController(或任何您喜欢的类),使其成为子类 UIViewController 确保您已选中"with xib for user interface"框.

  4. 打开appDelegate.h,放

@class ViewController;

之间@interface and #import,和以下这个属性:

@property (strong, nonatomic) UIViewController *viewController;
Run Code Online (Sandbox Code Playgroud)
  1. 打开appDelegate.m:导入ViewController

#import"ViewController.h"

之前

[self.window makeKeyAndVisible];
Run Code Online (Sandbox Code Playgroud)

 self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
Run Code Online (Sandbox Code Playgroud)


Fil*_*ght 10

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