0
votes

I've created a View Based Application in XCode4 and trying to do the code and UI design according to the way Apple have intended it to be.

So I designed the UI in the AppNameViewController.xib and it works fine; now I want to enable it as a UNIVERSAL application that runs on iPad as well. I changed the App-Target>>Summary>>Devices from iPhone to Universal and miraculously XCode had automatically created MainWindow-iPad.xib (Apple, very nice...), but since I designed the application first screen on the AppNameViewController.xib and not on the MainWindow.xib when I run the app on iPad Simulator I get this ugly screen where my UI objects size and location is distorted (their size is still set for iPhone so they are all crumbled on the left-top corner of the screen).

In my previous app I used the code appearing below to distinct between the AppNameViewControllerForIPHONE.xib and the AppNameViewControllerForIPAD.xib; It was done from the AppDelegate.m file, but in the new XCode View Based Application template the AppDelegate doesn't go through initWithNibName method at all.

Code I used on XCode 3 that cannot be used on XCode 4:


if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

viewController = [[AppViewController alloc] initWithNibName:@"AppViewControllerIPAD" bundle:[NSBundle mainBundle]];

}

else {

viewController = [[AppViewController alloc] initWithNibName:@"AppViewControllerIPHONE" bundle:[NSBundle mainBundle]];

}

Long question... still, anyone had any idea how it should be done here? Where should I design the iPad UI or is there a way to easily transform the iPhone xib to an iPad one?

1
I'm confused - above the code, it sounds like you need help figuring out which nib to load. Below the code, it sounds like you're asking how do you design the iPad UI. Please clarify what your question is. - RyanR
RyanR, I have created a View Based Application and selected "iPhone" in Device Family. I designed the UI on the xib file. Now I want to add an iPad xib, but I don't know how to direct the app to it. - Ohad Regev
You'll have to migrate the application to a Universal App. - RyanR

1 Answers

0
votes

You have to follow the new naming scheme (idiom in Apple-speak) specified for Universal Applications for the NSMainNibFile key in your info.plist. For example, if you set your NSMainNibFile to be "MainWindow-iPhone", the xib for ipad would be "MainWindow-iPad".

The same naming convention should hold for the views in a view based application (I can't test right now, installing new xcode).