从Web加载(并显示).XIB [英] Load (and display) a .XIB from the web

查看:111
本文介绍了从Web加载(并显示).XIB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够下载(通过NSURLConnection请求).XIB文件,并将其显示在视图中。我已经实现了NSURLConnection,当然,当连接完成时,我留下了表示XIB文件的XML数据的NSString。示例:(只是前几行)

I want to be able to download (via a NSURLConnection request) a .XIB file, and have it presented in a view. I have implemented the NSURLConnection, and surely enough, when the connection completes, I am left with a NSString of XML data representing the XIB file. Example: (just the first few lines of many)

<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
    <data>
        <int key="IBDocument.SystemTarget">800</int>
        <string key="IBDocument.SystemVersion">10D573</string>
        <string key="IBDocument.InterfaceBuilderVersion">762</string>
        <string key="IBDocument.AppKitVersion">1038.29</string>
        <string key="IBDocument.HIToolboxVersion">460.00</string>
        ET CETERA...

我查看了文档,我相信我不能使用initWithNibName:因为它是从Web检索的。我认为我需要做的是将.XIB保存到应用程序的文档目录,然后使用loadNibFile:externalNameTable:withZone:

I looked through the documentation, and I believe that I cannot use "initWithNibName:" because it is being retrieved from the web. What I believe I need to do is save the .XIB to the app's document directory, and then use "loadNibFile:externalNameTable:withZone:"

基本上我想做什么有一个iPad应用程序,并有一个小的320x480窗口,其中可以显示从Web加载的.XIB。如果我可以将它本地附加到ViewController更好,但不是完全必要的。

Essentially what I want to do is have an iPad application, and there is a small 320x480 window, where a .XIB loaded from the web can be displayed. If I can attach it locally to a ViewController all the better, but not completely necessary.

我只是不确定如何使用loadNibFile:externalNameTable:withZone :任何人都可以给我一些建议或示例吗?

I'm just not exactly sure how I should use "loadNibFile:externalNameTable:withZone:" Can anyone give me some advice or an example?

提前致谢!

推荐答案

loadNibFile:externalNameTable:withZone:是一个AppKit方法,所以它只适用于Mac OS,而不适用于iPhone或iPad。

loadNibFile:externalNameTable:withZone: is an AppKit method, so it only works on Mac OS, not iPhone or iPad.

在SDK 3.2中你可以use - [UIViewController initWithNibName:bundle:]或 - [NSBundle loadNibNamed:owner:options:],具体取决于您是否希望File的Owner为UIViewController。虽然你是对的,你无法下载.xib并将其安装到主包的资源中,你可以下载一个包,将其保存到你的Documents目录中,将其传递给+ [NSBundle bundleWithPath:],然后提取一个.xib来自它使用initWithNibName:bundle:或loadNibNamed:owner:options。

In SDK 3.2 you can use -[UIViewController initWithNibName:bundle:] or -[NSBundle loadNibNamed:owner:options:], depending whether or not you want the File's Owner to be a UIViewController. While you're right that you can't download a .xib and install it into your main bundle's resources, you can probably download a bundle, save it into your Documents directory, pass it to +[NSBundle bundleWithPath:], and then extract a .xib from it using initWithNibName:bundle: or loadNibNamed:owner:options.

我没有试过这个,但看起来应该可行。我很想知道它是不是。

I haven't tried this, but is seems like it should work. I'll be curious to know if it does.

我也很想知道Apple是否接受这个应用程序。看起来这会将iPhone SDK协议的第3.2.2节放到测试中。

I'll also be very interested to know if Apple accepts this app. It seems like this would put section 3.2.2 of the iPhone SDK Agreement to the test.

这篇关于从Web加载(并显示).XIB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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