Xcode6中如何切换storyboard为xib
来源:互联网 发布:数控铣削加工编程例题 编辑:程序博客网 时间:2024/04/28 02:03
在Xcode6中,当创建一个带View的iPhone项目时,默认必须使用Storyboards,不再支持切换xib的checkbox。本文讲解如何手动切换到使用xib来布局。
1,把Main.storyboard从项目中移除
2,添加xib文件到项目中。添加一个新文件,选择View,命名和*ViewContorller相同。
3,把Main storyboard对应的项从plist文件中移除
4,在*AppDelegate中添加类似代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
// Override point for customization after application launch.
TestViewController *test = [[TestViewController alloc] initWithNibName:
@"TestViewController"
bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return
YES;
}
如果ARC关闭的话,以上代码需要手动添加autorelease,这里不详述了。
5,可选:关闭ARC。 在项目的build setting中,找到 Objective-C Automatic Reference Counting, 设置为No
6,把xib关联到对应的ViewController上,否则会报如下错误
NibName[2203:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "loc" nib but the view outlet was not set.'
步骤(参考自 loaded some nib but the view outlet was not set):
1). 点击我们要加载的 xib 文件
2). 在右边选中 File's Owner
3). 在 File's Owner 的 选项卡的“Custom Class” 属性设置中,将 Class 的值改成对应的 VC, 这里改成 UIViewController,
4). 这时候,在File's Owner 的 选项卡中, 就 会出现“待连接设置” 的 view 属性, 也即我们的编译器 告诉我们的the view outlet was not set 中的 view。当 File's Owner 的 class 为 NSObject 时候,是没有 view 属性的。
连接 view 属性(把连线拖动到xib设计器中进行连接),
参考:
http://www.cnblogs.com/TivonStone/archive/2012/04/20/2460116.html
http://stackoverflow.com/questions/17234172/xcode-5-without-storyboard-and-arc
- Xcode6中如何切换storyboard为xib
- Xcode5中如何切换Storyboards为xib
- Xcode5中如何切换Storyboards为xib
- Xcode5中如何切换Storyboards为xib
- Xcode5中如何切换Storyboards为xib
- Xcode5中如何切换Storyboards为xib
- 在Xcode6+中使用xib代替storyBoard的操作步骤
- 如何去掉xcode6中新建工程自带storyboard
- Xcode6中如何去掉默认的Main.storyboard
- Xcode6中如何去掉默认的Main.storyboard
- Xcode6中如何去掉默认的Main.storyboard
- 如何在xib/storyboard中设置视图的属性,如圆角?
- xcode6 framework中使用xib
- 如何使用storyboard和xib
- Xcode6.x如何不使用storyboard
- Xcode6.1中xib的一个bug
- 为什么 iOS 开发中,xib跟storyboard拖得控件一般为 weak 而不是 strong
- Xcode6 中 StoryBoard 中的 Size Classes 注意事项
- K近邻法(knn)与k-means(附源代码)
- 博弈论—Nim游戏
- pdf文字提取软件该怎么选
- android 从网上解析Json获取天气情况
- Qt graphic item日记
- Xcode6中如何切换storyboard为xib
- rtti
- 搜索引擎-查询
- 第九周项目三—输出星号图
- iOS 本地通知
- SecureCRT连接linux终端颜色配置
- Oracle创建存储过程
- JSON-lib框架,转换JSON、XML不再困难
- "无法安装以下功能 .NET Framework 3.5 错误代码0x800F0906"的解决方案