Xcode 4 .xib Create iPad Version

前端 未结 9 2345
醉梦人生
醉梦人生 2020-12-01 01:28

I have an iPhone xib I want to turn into an iPad xib. In Xcode 3 there was a \"Create iPad Version\" menu option. How do I do this in Xcode 4?

I currently resized m

相关标签:
9条回答
  • 2020-12-01 02:06

    This worked for me:

    1. Make a copy of the .xib in the Finder.
    2. Open the copied file in a text editor.
    3. Change "com.apple.InterfaceBuilder3.CocoaTouch.XIB" to "com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB".
    4. Change all instances of "IBCocoaTouchFramework" to "IBIPadFramework".
    5. Search for sizes like {480, 320} and edit them. Or just reopen the file in Xcode and use the GUI to resize items as needed.

    This also works in reverse, if you need to change an iPad xib into an iPhone xib.

    0 讨论(0)
  • 2020-12-01 02:06

    You will have to use the older version of Interface Builder to use the "Create iPad version using autoresizing masks". There currently is no option in Xcode 4 that will do this.

    0 讨论(0)
  • 2020-12-01 02:07

    Another simple way in XCode4 is: Just copy the iPhone XIB in Finder; drag the copy in your project. Open the copied XIB in XCodes build in interface builder. Change the size of the top view in your NIBs hirarchy to iPads dimensions (e.g. 1024x748 for landscape with statusbar) - everything else resizes according to the autoresizing masks. Works perfect for me.

    0 讨论(0)
  • 2020-12-01 02:10

    in Xcode 4 it's quite hidden, but the option to convert XIBS in the app still exists.

    Select the target (in XCODE4 it's shown when you select the project). Once selected use the contextual menu to "Duplicate" it. It will ask if you want to "Duplicate and transition to iPad". Then all the XIBS will be duplicated with the new iPad size.

    0 讨论(0)
  • 2020-12-01 02:10

    On assessing my options, these were my thoughts:

    • Too much of a hassle to install xcode 3 and downgrade project
    • Don't want to mess with .xib file format - afraid it might break something that will show itself much later
    • Copying the same nib is imperfect (see the explanations in this thread)

    So finally, what I ended up doing that works fine is:

    1. Create a new file, choose "UIViewController derived" class
    2. Check the "intended for iPad" checkbox
    3. Name the file -iPad
    4. Delete the .h and .m corresponding to the uiviewcontroller
    5. Now populate the new nib with the same objects, structure and connections as the original nib
    6. Check if on iPad, if so then load the new nib else load the old nib
    0 讨论(0)
  • 2020-12-01 02:25

    Using XCode 4, all you have to do is select the (iPhone-specific) .xib file in the project navigator, then select File... --> Duplicate...

    Name the new .xib file the same as your iphone-specific one, but append ~ipad to the name. All your previous connections in the view hierarchy should be unchanged in your brand-new iPad-specific .xib file.

    0 讨论(0)
提交回复
热议问题