当我在xcode 5中创建一个新项目选择选项(单一视图应用程序)时,它会自动添加Main.storyboard,因为我们在之前版本的xcode中选择了.Xib文件,没有选项可供选择.Xib文件。 请有人解释一下
答案 0 :(得分:20)
我的建议是:
File/New/File
,选择Objective-C Class 为您的班级ViewController
(或您喜欢的任何内容)命名,将其设为UIViewController
的子类
确保您已选中“使用xib进行用户界面”框。
打开appDelegate.h
,添加
@class ViewController;
介于@interface and #import
和以下此属性之间:
@property (strong, nonatomic) UIViewController *viewController;
appDelegate.m:
导入ViewController #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。