So you started a universal iOS app and finished up everything on the iPhone XIB. Now it’s time to do the iPad XIB. But wait a minute, do we have to redo the whole thing? Isn’t it repetitive and tedious to all the mappings and connections all over again? The good thing is that there is a way around it. You only need to do minimal work to get your iPad XIB up and running on Xcode 4.
Here are the steps that you need to follow:
- Make a copy of the iPhone XIB file and add it to your project. Add the “_iPad” suffix to the new file before adding it to the project.
- Right click the file (in Xcode) and Open As > Source Code
- The second line should look like this:
<archive type=”com.apple.InterfaceBuilder3.CocoaTouch.XIB” version=”7.10″>
Replace it with this:
<archive type=”com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB” version=”7.10″>
- Search for “IBCocoaTouchFramework” and replace all occurrences with “IBIPadFramework”
- Save the file
- Open As > Interface Builder – iOS
The file might still be looking like a regular iPhone XIB. The reason is that some of the values are invalid by default in the Attributes Inspector. To change that, do the following:
- Select the iPad view and go to the Attributes Inspector.
- Change the value of “Size” to “iPad Full Screen”
- Change the value of “Status Bar” to “Black” from the dropdown menu.
Once you do this, the XIB will just snap into an iPad XIB. The whole thing is actually beautiful when you see it for the first time! All the mappings, connections and variables completely intact. You just need to change the size of your buttons and views, and you are good to go.