无法从iOS中的框架访问.nib(XIB)文件 [英] unable to access .nib(XIB) files from a framework in iOS

查看:300
本文介绍了无法从iOS中的框架访问.nib(XIB)文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从现有的代码库中创建了一个框架,并尝试在新的代码库中使用它。这很好用。但是当我尝试访问作为我的框架包的一部分的nib文件时,我的应用程序正在崩溃。这是我用来访问视图控制器XIB文件的代码。

i have created a framework out of my existing code base and tried using it in a new code base. This worked fine. But my application is getting crashed when i try to access the nib files which is a part of my framework bundle. This is the code i am using to access the view controllers XIB file.

testViewController * controller = [[testViewController alloc] initWithNibName:@testViewController 捆绑:无;
[self.view addSubview:controller.view];

应用程序崩溃而不会产生任何错误或崩溃报告。以下是我的问题

The app is getting crashed without generating any error or crash report. Here aremy questions

1 - 我们可以在框架中添加xib文件

2 - 如果,是的,从framawork添加和访问nib(xib)文件的正确方法是什么(目前我已将它们添加到编译源构建设置构建阶段标签的一部分

2 - If, yes, what is the correct way to add and access the nib(xib)files from a framawork(currently i have added them in the "compile sources" section of my "build phases" tab in "build settings")

推荐答案

您需要编写nib所在的包的名称。文件存储,所以将上面的代码更改为...

You need to write the name of the bundle in which you nib. files are store so change your above code to ...

testViewController *controller = [[testViewController alloc] initWithNibName:@"testViewController" bundle:yourBundle]; [self.view addSubview:controller.view];

此处您的捆绑包是NSBundle类型的对象。请参阅 NSBundle 课程了解更多信息

here your bundle is an object of type NSBundle. refer the NSBundle class for more info

这篇关于无法从iOS中的框架访问.nib(XIB)文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆