0

我在通用模式下创建了一个简单的计算器应用程序。我有两个 xib,一个用于 iphone,另一个用于 ipad。我只在 iphone 中创建了我所有的视图设计,我的 ipad xib 是空白的。现在,当我在 ipad 中部署我的 iphone 应用程序时,它的大小与 iphone 相当。我选择了自动调整大小选项。我是否必须在 ipad xib 中创建相同的 iphone 视图才能正确显示,还是有其他方法?这就是我的应用程序当前在 ipad 上的显示方式。我需要全屏模式。 ipad 视图

编辑:这是 iphone xib 的示例源代码。我应该如何修改它以适应 ipad?

    <?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
    <data>
        <int key="IBDocument.SystemTarget">1280</int>
        <string key="IBDocument.SystemVersion">10K549</string>
        <string key="IBDocument.InterfaceBuilderVersion">1938</string>
        <string key="IBDocument.AppKitVersion">1038.36</string>
        <string key="IBDocument.HIToolboxVersion">461.00</string>
        <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
            <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
            <string key="NS.object.0">933</string>
        </object>
        <array key="IBDocument.IntegratedClassDependencies">
            <string>IBUIView</string>
            <string>IBUIBarButtonItem</string>
            <string>IBProxyObject</string>
            <string>IBUIToolbar</string>
            <string>IBUITextField</string>
            <string>IBUITextView</string>
            <string>IBUITableView</string>
            <string>IBUITableViewCell</string>
            <string>IBUIButton</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="372490531">
                <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
                <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
            </object>
            <object class="IBProxyObject" id="843779117">
                <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
                <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
            </object>
            <object class="IBUIView" id="774585933">
                <reference key="NSNextResponder"/>
                <int key="NSvFlags">274</int>
                <array class="NSMutableArray" key="NSSubviews">
                    <object class="IBUITextField" id="234836822">
                        <reference key="NSNextResponder" ref="774585933"/>
                        <int key="NSvFlags">292</int>
                        <string key="NSFrame">{{12, 48}, {286, 31}}</string>
                        <reference key="NSSuperview" ref="774585933"/>
                        <reference key="NSNextKeyView" ref="1066176330"/>
                        <bool key="IBUIOpaque">NO</bool>
                        <bool key="IBUIClipsSubviews">YES</bool>
                        <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
                        <int key="IBUIContentVerticalAlignment">0</int>
                        <string key="IBUIText">0</string>
                        <int key="IBUIBorderStyle">3</int>
                        <object class="NSColor" key="IBUITextColor">
                            <int key="NSColorSpace">3</int>
                            <bytes key="NSWhite">MAA</bytes>
                            <object class="NSColorSpace" key="NSCustomColorSpace">
                                <int key="NSID">2</int>
                            </object>
                        </object>
                        <int key="IBUITextAlignment">2</int>
                        <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
                        <float key="IBUIMinimumFontSize">17</float>
                        <object class="IBUITextInputTraits" key="IBUITextInputTraits">
                            <int key="IBUIKeyboardType">4</int>
                            <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
                        </object>
                        <object class="IBUIFontDescription" key="IBUIFontDescription" id="1025764138">
                            <int key="type">1</int>
                            <double key="pointSize">14</double>
                        </object>
                        <object class="NSFont" key="IBUIFont" id="891898266">
                            <string key="NSName">Helvetica</string>
                            <double key="NSSize">14</double>
                            <int key="NSfFlags">16</int>
                        </object>
                    </object>
                    <object class="IBUIButton" id="1066176330">
                        <reference key="NSNextResponder" ref="774585933"/>
                        <int key="NSvFlags">292</int>
                        <string key="NSFrame">{{41, 102}, {50, 50}}</string>
                        <reference key="NSSuperview" ref="774585933"/>
                        <reference key="NSNextKeyView" ref="182110945"/>
                        <bool key="IBUIOpaque">NO</bool>
                        <int key="IBUITag">1</int>
                        <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
                        <int key="IBUIContentHorizontalAlignment">0</int>
                        <int key="IBUIContentVerticalAlignment">0</int>
                        <int key="IBUIButtonType">1</int>
                        <string key="IBUINormalTitle">1</string>
                        <object class="NSColor" key="IBUIHighlightedTitleColor" id="899681977">
                            <int key="NSColorSpace">3</int>
                            <bytes key="NSWhite">MQA</bytes>
                        </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="10.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="101.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="103.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="104.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="105.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="106.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="11.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="111.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="12.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="13.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="14.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="15.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="16.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="17.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <real value="0.0" key="17.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
                <string key="18.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="19.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="20.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="21.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="22.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="23.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="24.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="25.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="36.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="69.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="78.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="82.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="83.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="9.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                <string key="94.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">125</int>
        </object>
        <object class="IBClassDescriber" key="IBDocument.Classes"/>
        <int key="IBDocument.localizationMode">0</int>
        <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
        <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
        <int key="IBDocument.defaultPropertyAccessControl">3</int>
        <string key="IBCocoaTouchPluginVersion">933</string>
    </data>
</archive>
4

6 回答 6

1

我建议使用自动布局。如果您使用 iPhone 的自动布局来查看视图,它在 iPad 上看起来几乎相同,只是更大。自动布局在 XIB 中非常简单。另一种可能性是为 iPad 布局创建单独的 XIB。如果您这样做,只需查看描述如何轻松做到这一点的其他答案。

于 2013-08-20T08:26:15.800 回答
1

右键单击 XIB。

选择打开方式。

选择源代码。

并在其中修改以下内容:

 <object class="NSArray" key="dict.values">
    <bool key="EncodedWithXMLCoder">YES</bool>
    <string>{320, 480}</string>
    <string>{480, 320}</string>
    </object>

至:

<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{768, 1024}</string>
<string>{1024, 768}</string>
</object>

That's it.
于 2013-08-20T05:55:49.637 回答
0

在 iPhone xib 文件中,将目标从 iOS.CocoaTouch 更改为 iOS.CocoaTouch.iPad,现在如果您在界面生成器中打开该文件,您将看到 iPad 的设置。

于 2014-02-13T21:41:15.877 回答
0

您需要制作两个单独的 xib 并管理所有按钮、文本字段并将所有这些添加到 New Xib 中...

从 iphone xib 创建 Ipad Xib 的方法......

1)首先复制iphone xib并粘贴只需更改名称,如~ipad.xib给出并将其添加到捆绑包中

2)现在你有一个 2 xib 1 用于 iphone 和 1 用于 ipad。

3)转到ipad xib右键单击它看到打开为->在源代码中打开它然后你必须找到320,480值在源代码中搜索该值并更改为

768,1024...

就是这样做的....

于 2013-08-20T06:00:22.340 回答
0

是的!!!iPad您还必须在其他Xib文件中创建视图。

于 2013-08-20T05:58:17.660 回答
0

将 iPhone xib 转换为 iPad xib?

请参阅 Jag 的回答……他在哪里声明,

我能够将其缩小到几件事,所以以下是对我有用的步骤:

1)制作iPhone xib文件的副本并将其添加到您的项目中

2)右键单击文件(在xcode中)并打开为>源代码

3)第二行应如下所示:

用。。。来代替:

4) 搜索“IBCocoaTouchFramework”并将所有出现的地方替换为“IBIPadFramework”

5) 保存文件并打开为 > Interface Builder - iOS

该文件可能仍然看起来像一个普通的 iPhone xib,但对我来说,一旦我在属性检查器中将状态栏更改为“黑色”,其余的 xib 只是有点“捕捉”到 iPad xib

编辑:您也可以这样做==>将 iphone App 转换为 iPad

1) 选择通用选项。

2) 将代码从现有 iPhone 项目转移到新项目。

3) 现在,为 iPad 制作 xib 文件,并建立连接 (IBOutlets)。

无论您需要平台特定的功能(例如,iPad 的 Popover、Split ViewController 等),放置一个 IF 语句来处理设备特定的功能。

于 2013-08-20T06:04:17.543 回答