将XML文件转换为Nib文件?

时间:2012-12-01 05:42:03

标签: iphone objective-c ios xml

我想知道在objective-c中从XML文件转换为Nib文件,我的需求通常是编译后的Xib文件,它将转换为NIB文件(二进制数据格式)现在我想给外部Xml文件Project和我想将此文件转换为Nib文件。这可能吗?给我建议(这意味着用XML文件替换Xib文件)。

1 个答案:

答案 0 :(得分:0)

这里我列出了普通iPad xib配置的详细信息,它以plist的形式出现。

<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="8.00">
    <data>
        <int key="IBDocument.SystemTarget">1536</int>
        <string key="IBDocument.SystemVersion">12A206j</string>
        <string key="IBDocument.InterfaceBuilderVersion">2519</string>
        <string key="IBDocument.AppKitVersion">1172.1</string>
        <string key="IBDocument.HIToolboxVersion">613.00</string>
        <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
            <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
            <string key="NS.object.0">1856</string>
        </object>
        <array key="IBDocument.IntegratedClassDependencies">
            <string>IBProxyObject</string>
            <string>IBUIView</string>
        </array>
        <array key="IBDocument.PluginDependencies">
            <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
        </array>
        <object class="NSMutableDictionary" key="IBDocument.Metadata">
            <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
            <integer value="1" key="NS.object.0"/>
        </object>
        <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
            <object class="IBProxyObject" id="841351856">
                <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
                <string key="targetRuntimeIdentifier">IBIPadFramework</string>
            </object>
            <object class="IBProxyObject" id="606714003">
                <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
                <string key="targetRuntimeIdentifier">IBIPadFramework</string>
            </object>
            <object class="IBUIView" id="766721923">
                <reference key="NSNextResponder"/>
                <int key="NSvFlags">274</int>
                <string key="NSFrame">{{0, 20}, {768, 1004}}</string>
                <reference key="NSSuperview"/>
                <reference key="NSWindow"/>
                <object class="NSColor" key="IBUIBackgroundColor">
                    <int key="NSColorSpace">3</int>
                    <bytes key="NSWhite">MQA</bytes>
                    <object class="NSColorSpace" key="NSCustomColorSpace">
                        <int key="NSID">2</int>
                    </object>
                </object>
                <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics">
                    <int key="IBUIStatusBarStyle">2</int>
                </object>
                <string key="targetRuntimeIdentifier">IBIPadFramework</string>
            </object>
        </array>
        <object class="IBObjectContainer" key="IBDocument.Objects">
            <array class="NSMutableArray" key="connectionRecords">
                <object class="IBConnectionRecord">
                    <object class="IBCocoaTouchOutletConnection" key="connection">
                        <string key="label">view</string>
                        <reference key="source" ref="841351856"/>
                        <reference key="destination" ref="766721923"/>
                    </object>
                    <int key="connectionID">3</int>
                </object>
            </array>
            <object class="IBMutableOrderedSet" key="objectRecords">
                <array key="orderedObjects">
                    <object class="IBObjectRecord">
                        <int key="objectID">0</int>
                        <array key="object" id="0"/>
                        <reference key="children" ref="1000"/>
                        <nil key="parent"/>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">-1</int>
                        <reference key="object" ref="841351856"/>
                        <reference key="parent" ref="0"/>
                        <string key="objectName">File's Owner</string>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">-2</int>
                        <reference key="object" ref="606714003"/>
                        <reference key="parent" ref="0"/>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">2</int>
                        <reference key="object" ref="766721923"/>
                        <reference key="parent" ref="0"/>
                    </object>
                </array>
            </object>
            <dictionary class="NSMutableDictionary" key="flattenedProperties">
                <string key="-1.CustomClassName">ViewController</string>
                <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="-2.CustomClassName">UIResponder</string>
                <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
            </dictionary>
            <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
            <nil key="activeLocalization"/>
            <dictionary class="NSMutableDictionary" key="localizations"/>
            <nil key="sourceID"/>
            <int key="maxID">3</int>
        </object>
        <object class="IBClassDescriber" key="IBDocument.Classes">
            <array class="NSMutableArray" key="referencedPartialClassDescriptions">
                <object class="IBPartialClassDescription">
                    <string key="className">ViewController</string>
                    <string key="superclassName">UIViewController</string>
                    <object class="IBClassDescriptionSource" key="sourceIdentifier">
                        <string key="majorKey">IBProjectSource</string>
                        <string key="minorKey">./Classes/ViewController.h</string>
                    </object>
                </object>
            </array>
        </object>
        <int key="IBDocument.localizationMode">0</int>
        <string key="IBDocument.TargetRuntimeIdentifier">IBIPadFramework</string>
        <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
        <int key="IBDocument.defaultPropertyAccessControl">3</int>
        <bool key="IBDocument.UseAutolayout">YES</bool>
        <string key="IBCocoaTouchPluginVersion">1856</string>
    </data>
</archive>

但是没有关于plist中元素的文档。

我找到的一个解决方案是通过创建类似的XIB文件并使用其plist进行检查。 并尝试此操作,将此plist数据写为扩展名为.xib并加载该文件。

这个链接可以帮助你,

here

感谢,

Naveen Shan