通过静态库从Custom Bundle加载XIB

[英]Load XIB from Custom Bundle via Static Library


I want to load a XIB from a CFBundle, via some code in a Static Library.

我想通过静态库中的一些代码从CFBundle加载XIB。

Example:

例:

MyViewController * foo = [[Static Library] instance] getMyViewController];

So I have a MyViewController .xib in a CFBundle I manually create, in it's Resources dir.

所以我在CFBundle中有一个MyViewController .xib我手动创建,在它的资源目录中。

But if I try to load it via [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:MyBundlePointer] in getMyViewController I get NSInternalInconsistencyException.

但是如果我尝试通过[[MyViewController alloc] initWithNibName:@“MyViewController”bundle:MyBundlePointer]在getMyViewController中加载它,我得到NSInternalInconsistencyException。

Any idea? I am more or less stumped on this one. Not sure it is even possible to do this.

任何想法?我或多或少地难以接受这一点。不确定甚至可以做到这一点。

2 个解决方案

#1


0  

I'm currently having exactly the same issue with Monotouch and that's why I found your question. I get the very same exception as you do. This makes me assume that I'm not facing a Monotouch issue but a basic (mis)behavior of XIBs/Cocoatouch.

我目前与Monotouch有完全相同的问题,这就是我找到你的问题的原因。我和你一样得到了同样的例外。这使我假设我没有遇到Monotouch问题,而是XIB / Cocoatouch的基本(错误)行为。

So the answer is: no, it is not possible. Very sad though.

所以答案是:不,这是不可能的。虽然很伤心。

René

勒内

#2


0  

this may not be your specific issue, but it is potentially an issue:

这可能不是您的具体问题,但可能是一个问题:

CFBundle is not toll-free-bridged with NSBundle. since you used the term CFBundle in your description, i am wondering if you're passing a CFBundle, rather than an NSBundle.

CFBundle与NSBundle没有免费桥接。既然你在你的描述中使用了CFBundle一词,我想知道你是否通过CFBundle,而不是NSBundle。

these are two distinct types and you'll need to explicitly create an NSBundle instance because you can't just cast a CFBundleRef as a NSBundle as you can with CF/NS-String, Array, Data, etc.

这是两种不同的类型,您需要显式创建一个NSBundle实例,因为您不能像使用CF / NS-String,Array,Data等那样只将CFBundleRef转换为NSBundle。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2011/01/03/69f5c961b8fafff8e273afe77351ba11.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号