创建使用 Xibs 的静态框架...如何?
我需要创建一个 UI 类的包装,开发人员可以将其包含在 XCode4 集成项目中,然后通过结合使用配置文件来实例化使用 NSClassFromString - 一个静态插件。我已经成功创建了包含基于代码布局的 UIView 的库。现在我试图允许开发人员基于 xib 文件和其他资源创建 UI。我正在实现这个的最基本版本...UIViewController 加载直接通过 XCode4 中的“新文件”向导创建的 xib 文件。我所做的唯一修改是向 xib 中的 UI 添加一个标签。
我在加载 xib 时遇到问题。如果我将 xib 包含在集成项目中,一切都会很好。当我从库创建 UIViewController 时,它会在应用程序包的根目录中找到 xib 并加载它。然而,这在构建集成项目期间非常麻烦,我希望能够仅链接到库,而不必将每个 xib 添加到单独的集成项目。此外,使用应用程序包的根目录也不好,因为没有可以支持多个静态插件的目录结构。我尝试创建一个文件夹,集成项目可以在其构建过程中包含该文件夹,并且静态插件的 xib 可以在之前转储到文件夹中建造。如果我这样做,xib 会进入应用程序包,但是当 UIViewController 类加载时,它找不到 xib。当 xib 位于子文件夹中时,我无法编写解决方案以使 UIViewController 正确地进入 initWithNibName:bundle: 。
我的最后一次尝试是使用本文创建静态框架: http://simplyitinc.blogspot.com/2011/04/creating-static-framework-in-xcode-4.html。这似乎为我提供了一个可以链接的框架,并且 xib 位于该框架目录中,但是......当我链接框架时,xib 不会被放入应用程序包中。我的类可用,但无法加载 xib,显然是因为它不在应用程序包中。
关于如何实现这一要求有什么建议吗?
I have a need to create a packaging of UI classes that can be included in an XCode4 integration project by a developer and then get instantiated through the use of a config file in conjunction with NSClassFromString - a static plugin. I have had success with creating libraries that contain UIViews that layout based on code. Now I am trying to allow the developer to create UIs based on xib files and other resources. I am implementing the most basic version of this...a UIViewController loading a xib file created directly through the "new file" wizard in XCode4. The only modification I am making is adding a label to the UI in the xib.
I am having problems getting the xib loaded. If I include the xib in the integration project all is well. When I create the UIViewController from the library it finds the xib in the root of the app bundle and loads it. However, this is very cumbersome during the build of the integration project, I would like to be able to just link to the library and not have to add each xib to the integration project individually. Additionally the use of the root of the application bundle is bad because there is no directory structure that could facilitate multiple static plugins. I have tried creating a folder that the integration project can include during its build and the xibs for the static plugin can just be dumped into folder prior to build. If I do this the xib gets into the app bundle but when the UIViewController class loads up it cannot find the xibs. I have been unable to code a solution to get the UIViewController to initWithNibName:bundle: properly when the xibs are in the sub-folder.
My last attempt has been to create a static framework using this article: http://simplyitinc.blogspot.com/2011/04/creating-static-framework-in-xcode-4.html . That seems to get me a framework I can link against and the xib is in that framework directory but ... the xib does not get placed into the app bundle when I link against the framework. My classes are available but fail to load the xib, obviously because it is not in the app bundle.
Any suggestion on how this requirement might be accomplished?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论