0

I created a simple calculator app in universal mode. I have two xib one for iphone and other for ipad. I created all my view design only in iphone, my ipad xib is blank. Now when I deployed my app for iphone in ipad, it comes in the size of iphone. I have choosen the autoresize option. Will I have to create same view of iphone in ipad xib for the correct display or is there any other way? This is how my app currently displays on ipad. I need it in a full screen mode. ipad view

EDIT: This is the sample source code of iphone xib. How should I modify this to fit for 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>
Francis F
  • 3,157
  • 3
  • 41
  • 79
  • you have to create new xib for ipad and then check which device is running the app and then open xib accordingly... you can create xib for ipad with same name after that "~ipad" mention before .xib ... – Bhrigesh Aug 20 '13 at 05:51
  • @Bhrigesh I already have a xib for ipad. As mentioned in my question I want to know whether I have to recreate all the buttons and textfield in the ipad xib as well? – Francis F Aug 20 '13 at 06:03
  • yes ... you have to set frame for each button which fits the whole screen for ipad... – Bhrigesh Aug 20 '13 at 06:06
  • @Gamerlegend Yes you have to create all the controls and view in you iPad view also, that is the best way and will give good result. – Suryakant Sharma Aug 20 '13 at 06:08
  • @SuryakantSharma is there an easy way to copy all the buttons and text field in iphone to ipad xib? – Francis F Aug 20 '13 at 06:30
  • yes, you can copy all view from iPhone_view and paste in iPad_view. simple copy+paste will work. once you copy all view adjust them according to your iPad_View. – Suryakant Sharma Aug 20 '13 at 06:56

6 Answers6

1

Right click on XIB.

Choose open as.

Choose Source code.

And in it modify following:

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

to:

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

That's it.
Jitendra
  • 5,055
  • 2
  • 22
  • 42
Aniket Kote
  • 541
  • 3
  • 9
  • How about the location/position of buttons(subviews) inside the superview that your forcing to resize? – Master Stroke Aug 20 '13 at 05:59
  • That also you can resize by modifying their frames in same way, that you did with xib.Either opening it in source code mode or as interface builder. Or you can just select the UIControls which you want to resize and copy it and paste it wherever you want on xib. And then you can adjust their frames. – Aniket Kote Aug 20 '13 at 07:04
1

I suggest using AutoLayout. If you do your view with auto layout for iPhone it will look nearly the same on the iPad, just bigger. AutoLayout is pretty easy in XIBs. The other possibility is to create a separate XIB for the iPad layout. If you do so just have a look at the other answers which describe how to do that easily.

0

Yes!!! You have to create view for iPad also in other Xib file.

Suryakant Sharma
  • 3,852
  • 1
  • 25
  • 47
0

You need to make two seprate xib and manage all buttons,textfiels and add all these in New Xib...

Way To Create Ipad Xib from iphone xib....

1)First copy iphone xib and paste just change the name like ~ipad.xib give and add it to the bundle

2)now you have an 2 xib 1 is for iphone and 1 is for ipad.

3)go to ipad xib right click on in it see open as -> open it in source code and then you have to find 320,480 value search that value in source code and change into

768,1024...

that's it do this way....

Jitendra
  • 5,055
  • 2
  • 22
  • 42
0

From Converting iPhone xib to iPad xib?

Refer Jag's answer..where he States that,

I was able to narrow it down to a few things, so here are the steps that worked for me:

1) Make a copy of the iPhone xib file and add it to your project

2) Right click the file (in xcode) and Open As > Source Code

3) The 2nd line should look like:

Replace with:

4) Search for "IBCocoaTouchFramework" and Replace all occurrences with "IBIPadFramework"

5) Save the file and Open As > Interface Builder - iOS

The file might still look like a regular iPhone xib, but for me, once I changed the Status Bar to "Black" in the Attributes inspector the rest of the xib just kind of "snapped" into an iPad xib

EDIT : You can also do in this way==>convert iphone App to IPad

1) Select the Universal option.

2) Transfer code from the existing iPhone project to the new project.

3) NOW,Make the xib files for iPad, and make the connections (IBOutlets).

Wherever you need platform specific features (eg. Popover, Split ViewController etc for iPad), put an IF statement to handle the device specific features.

Community
  • 1
  • 1
Master Stroke
  • 5,108
  • 2
  • 26
  • 57
0

In iPhone xib file change the target from iOS.CocoaTouch to iOS.CocoaTouch.iPad, and now if you open the file in interface builder, you will see settings for iPad.