Creating ipad version from iphone version? - iphone

I've developed an iPhone app. I want to make the same application version of iPad. What you need to change the version of iPhone? What do I need for iPad version? Do I just change my UI design or are there any places in the code have to change?
Thanks,

You need to change the device in the summary (Project in proejct navigator -> App under Targets -> Summary -> Device -> iPad/iPhone/Universal). You can check which device the app is running on with this code. Then you can load different xib files and adjust your views for the specific device.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPhone" bundle:nil] autorelease];
} else
{
viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPad" bundle:nil] autorelease];
}

choose your project file in project navigator, then choose your target -> summary -> iOS Application target -> make sure it is iPad camatible. Then only design left...

Select the target and further go in bundle settings
go to deployment tab and then select the "iPad" in "targeted Device family"
then convert all Xibs with the ipad resolution.

Related

iOS - Converting iPhone Build to iPad

I have a application that I built that was to be build as an iPhone-only application.
Now, I am told that the application has to be made universal now. I will have to make it iPad compatible too (in portrait-only mode). I have been looking for my options right now as the XIBs in this project are heavily loaded with objects so programatically assigning co-ordinates will be a pain.
I am looking for the best, and the quickest approach I should take to make this iPhone app into iPad-compatible app as well.
PS: There is no mainwindow.xib file as the application was built with XCode 4.3 which doesn't create the MainWindow.xib file.
Thank you in advance.
EDIT: I have made duplicate XIBs for iPad for all the XIBs. Now, I am trying to use the naming convention which tells me to change the filename suffix to MyiPadXIB~ipad.xib and when the app is run on iPad, it will automatically take that XIB. This doesn't seem to be happening.
When I open the application in iPad, only a small window appears (the window that appears when iPhone-only app is run on an iPad).
Any solution to this?
I followed a very easy approach where I would just create duplicate XIBs of all the XIBs by doing Build settings > target (iPhone)> right click and choose duplicate.
I would then change the name of the duplicate xibs in this format: "iPhone XIB name"~ipad.xib.
The system would then automatically pick up the XIB according to the device used.
From what I know (there may be a quicker/better approach that i dont know of)
You would create seperate xib files for the ipad
when you init your view controller you check to see what device you are on like so
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.serverSettingsViewController = [[ServerSettingsViewController alloc] initWithNibName:#"ServerSettingsViewController_iPhone" bundle:nil];
self.motionJpegViewController = [[MotionJpegViewController alloc] initWithNibName:#"MotionJpegViewController_iPhone" bundle:nil];
} else {
self.serverSettingsViewController = [[ServerSettingsViewController alloc] initWithNibName:#"ServerSettingsViewController_iPad" bundle:nil];
self.motionJpegViewController = [[MotionJpegViewController alloc] initWithNibName:#"MotionJpegViewController_iPad" bundle:nil];
}
And load you iphone or ipad xib file (FYI make sure the xib views are large enough for the ipad)

iOS equivalent to Android Fragments/Layouts

In Android you can use Fragments to develop only one app targeted to phones and tables, so you can have different UI. You can even use only Layouts and have some condition on the code to run tablet or phone logic.
I need to develop an app for iPhone and iPad and I wonder if there is something similar for implementing different UIs and slighty different behavior. In my case the iPhone app would use tabs at the bottom of the screen, but the iPad one should use the menu on the left side.
Yes you can use Different UI for iPhone and iPad.
Create Two XIB files and when showing them on the screen use this condition to initiate the XIB
UIViewController *viewController;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPhone" bundle:nil] autorelease];
} else {
viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPad" bundle:nil] autorelease];
}
[self.navigationController pushViewController:viewController animated:YES];
UIViewController and XIB, respectively.
Also see Creating a Universal App.

Creating universal app for Xcode 4.3?

I am little bit confused about creating universal application for iOS devices using Xcode 4.3 , later versions (Xcode 4) have separate folder classes for this, but how will we make this using newest version of Xcode?
Thanks in advance
I don't think this has changed in Xcode 4.3 compared to previous versions of Xcode 4.* , but though you have a doubt refer to my answer below.
If you want to create a new project as Universal App then select Universal in Device Family in below image:
Or if you are trying to convert an existing iPhone or iPad app to Universal app then select Devices as Universal from Target Settings- > Summary Tab, set Devices to Universal:
Hope this helps you.
EDIT:
Let us suppose View Controller name is YourViewController
Let us suppose name of iPad XIB is YourViewController-iPad.xib and iPhone xib name is YourViewController.xib
YourViewController *yourViewController;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) //This is iPad
{
// iPad-specific interface here
yourViewController = [[YourViewController alloc] initWithNibName:#"YourViewController-iPad" bundle:nil];
}
else // This is iPhone or iPod
{
// iPhone and iPod touch interface here
yourViewController = [[YourViewController alloc] initWithNibName:#"YourViewController" bundle:nil];
}
Let me know if you need more help.
just select device family as universal while creating the project,
watch this screen shot
well you need to create two xib's, one for iPhone and one for iPad and just use
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
here open your iPad xib
} else {
here open your iPhone xib
{

Make an iPad app from an existing iPhone app?

If I wanted to make an iPad app from an existing iPhone app that I have released, would I have to create a new project targeted for iPad and create a new app ID and provisioning profile etc, and if so can the app have the same name? Or, do I create it within the existing iPhone targeted project.
Apologies if this question isn't technical enough for this forum...
Thanks.
You can create it within the existing iPhone project. Keep the same app ID. Apple will be delighted that you've gone universal. :) I'm assuming here that you mean to go universal. If you mean two separate apps, one for iPhone and one for iPad, that's two different apps; you can share code by using the same project, but they will have different targets and different IDs.
If you don't want to drag all your files over to a new project, i recommend the following:
In your build settings, deployment change the targeted device family to iPad / iPhone from iPhone.
Then for xib files you want to add you iPhone and iPad nib file to the project and an if statement calling the specified nib... I recommend just creating a simple view based project (that is Universal) and then looking at the code... You will see something like this.
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPhone" bundle:nil] autorelease];
} else {
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPad" bundle:nil] autorelease];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
You might have to add some supported orientations in you App-Info.plist for the iPad too.
More information can be found here in the section about Universal apps:
http://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/iPhoneAppProgrammingGuide.pdf
E.

Adding iPad XIB/VIEW to a "View Based Application" in iOS 4

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?
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).