I'm wondering if it's possible to make the iPhone app project I have into an iPad project? So I won't have to redo all coding and connecting everything again. I've gotten that far that I can make the iPhone project run on the iPad but then it's only in the iPhone's size.
I hope this makes sense!
Thank you in advance.
You'll probably need to recreate all those views as iPad views instead of iPhone views. Both would be included into the universal app in a single distribution binary. At runtime, load them dynamically based on the platform.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// The device is an iPad running iOS 3.2 or later. load the appropriate Xibs
}
else {
// The device is an iPhone or iPod touch. load the appropriate Xibs
}
See Creating a Universal Application
You may be able to design some views to dynamically stretch / resize and won't have to touch them much, however I suggest you tailor the tablet experience more than just "upsized", otherwise you aren't doing the device justice.
Related
Now I need to redesign an app(iPad version), it can run on iPad successfully .The targeted device family is iPad, and I want it run on iPhone.So I already changed the targeted family to iPhone, but it cannot run. It is because the size of the iPad and iPhone is different, so how can i make it successful to run on iPhone? Do I need to create a new xib for iPhone?How to achieve it?
Yes, you need to create new XIB's that are structured for the smaller interface. You will also need to determine in code what view you are loading for which device.
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
/* do something for the iPad */
else
/* do something for the iPhone */
Yes, you will need to create new /xibs for iPhone, an iPad App won't work on an iPhone like that. Not only the sizes are diferent, the ratio width/height is different too
If you really worked at it, you could use the xib file for both the iPad and iPhone. But first you have to make sure that your existing xib files don't have a "~ipad" in them, because if they do, they will only be loaded on the iPad and not the iPhone.
You may also want to make your app Universal instead of two separate iPhone and iPad apps.
And if you use a SplitViewController, you will have to add separate code for the iPhone. Same thing with UIPopovers.
Absolutely you have to redesign all UI corresponding to device screen size. You can create new xib or Storyboard separately for iPhone, So that you can achieve it.
You may use UIPopoverController in iPad but it won't work in iPhone, you have to present that viewcontroller in iPhone. From that you can manage that.,
its so simple you have to change the xib file and other code will be same
You can create xib from
New File -> user interface => view
I had created an iPhone app long time back. Now I want to kind of convert the same into an iPad app (the code would more or less remain the same, I only want to redesign the xib for iPad size).
Now I am using XCode 4 and after opening the app, I changed the devices to iPad. But my .xib are still showing iPhone size.
It created an iPad folder (just like Classes/Resources/Products...).
Also to add, the app now opens an iPad simulator, but let's say I have a UIWebView which just stretches to iPhone size (as in IB) and not the complete iPad size...
How and where do I redesign the xib for iPad ? What are the updates to be made when we just change the devices from iPhone to iPad ? Also I guess an iPhone app would work on iPad (using 2x), but the reverse is not true.
You should look into creating a Universal app which basically has shared code and libraries for the iPhone and iPad but different view layers (views or XIBs).
In that model you have different interfaces for both which you should. The paradigms are different - in iPhone you have small real estate so you have navigators that drill in and pop out. In iPad, you have more real estate so you have master/detail splitter views with pop-over controls. As you pointed out, even the web views are different sizes at a minimum.
If you start fresh you can create a universal app and get a feel for how it's laid out. File, new project, iOS, pick app type, next. For device family select Universal.
If you are converting, there's some resources out there. Here's some:
http://useyourloaf.com/blog/2010/4/7/converting-to-a-universal-app-part-i.html
How to convert iPhone app to universal in xcode4, if I previously converted, but deleted MainWindow-iPad?
Convert simple iPhone app to Universal app
I find it easiest to open the xibs in the separate Interface Builder that came with previous (3.2?) XCode and use its "convert to iPad using autoresize masks" option. Then I include the new separate XIBS in the project and do conditional loading (eg - use the UI_USER_INTERFACE_IDIOM() makro to load one xib or another.)
I'm working on an iPhone app, and decided to look into making it universal. If I set my build settings to target iphone/ipad, a lot of sizes and alignments get buggered (as I expected), and just generally it doesn't look good.
If I only target iPhone, but run it on the iPad, and hit the 2x button, it looks great. I'd like to release my app on the app store for the iPad, despite leaving the targeted platform as the iPhone since it looks and works much better.
I'm wondering if that will be an issue when I submit? Can you only release apps for iPad on the store if they target iPad?
Thanks!
If you develop for the iPhone you will want to use interface "xib" files that have all the correct sizing for the iPhone/iPod. iPad will be allowed to use the application
In your plist you will have the option of giving a startup xib file [NSMainNibFile] for the application to start with.
Or you can alternatively include [NSMainNibFile~ipad] and compile it for Universal. This will tell the ios that it should open NSMainNibFile for the iPhone/iPod and should open NSMainNibFile~ipad for the iPad.
There are a number of other settings that would need to be set for the ipad's icon, default screen among other items. But the Nib file settings are the most needed.
then you have separate xib file's for each platform. Conforming to the Model-View-Controller setup it would be relatively simple to attach your new view(xib) to your existing controller(.h/.m) and wire up a new look to your code and make an entirely new app..
Some sections of code will need to be changed dependent on weather you are on the iPad or the iPod.
(e.g. Layout, Special iPad/iPod only features etc.)
Here is the code I use do determine if I am on the iPad.
#define IS_IPAD() ([[UIDevice currentDevice] respondsToSelector:#selector(userInterfaceIdiom)] ? \
[[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad : NO)
Some developers dont comply totally with the MVC paradigm so your project may require some retooling to be able to function on both platforms. But if you are able to pinpoint the places that differentiate from one platform to another then your application will be able to function seamlessly on both platforms. (Likely with a better layout on the iPad as there is more real estate do play with when laying out your controls)
Alternatively if you want the application to be iPhone style but run on the iPad, It already does that by default.
If you target the iPhone (so that it will appear in 1x/2x mode on the iPad) it will only appear in the iPhone App Store.
iPad Users will still be able to download the app, but it will be in the iPhone Apps section.
So unless you explicitly target the iPad, it won't appear on the iPad store. You could consider redoing the graphics and alignments for the iPad app and sell it as a HD app.
If you need it to be universal look at doing something like this:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
controller = [[MyController alloc] initWithNibName:#"MyiPadNib" bundle:nil];
else
controller = [[MyController alloc] initWithNibName:#"MyiPodNib" bundle:nil];
You application will only be viewable in the iPad section of the store if it specifically targets iPad (is either iPad only, or a universal application).
What you are talking about is an iPhone application running on an iPad: where you are opting to only target iPhone devices. These apps will not be shown in the iPad section of the store.
Think of it as an incentive by Apple to get you to design an app that behaves well on iPad and iOS.
Remember, iPad users can still download iPhone only apps through the store, they're just in a separate section.
I have an iPhone app I developed using cocos2d. I have the correct version which supports iPad. Now, how do I get it to change the screen resolution or to recognize that it is an iPad app and not an iPhone app?
You can use the UI_USER_INTERFACE_IDIOM() to figure out in what kind of device your app is running. Anyway, you should always try to layout your stuff relative to the screen size (or the root view controller's view size) so that it will adapt itself to any resolution.
You can make your app use the entire iPad screen and not run in the simulator simply by changing the target device from iPhone to iPhone/iPad in Xcode. If you want your app to show different UI and run different code on the iPad, you can check for the device by using one of several ways to detect an iPad in Objective-C.
My question is simple:
1. I made an iphone app all done in cocos2d.
2. I adapted it to iphone4-retina, with all PNG files have their -hd copy.
Run in iPhone, the app displayed correctly (320x480).
Run in iPhone4-retina, the app also displayed correctly (640x960).
But run in iPad, if the app is set to iPhone only, it run correctly, but only as iPhone resolution (320x480). If the app is set to iPhone/iPad, of cause it will display wrong.
I'm sure there should be an option that force a retina-compitable iPhone app also run as retina on iPad (apple guys cannot be silly enough to miss it), but I just couldn't find it.
Where's the option? Or, is there an alternative that cocos2d has a same-easy switch to do the job? I do not need suggestions such as using relative coordinates or anything requires modifications more than twenty code-lines.
As far as I know, there is no automatic adaptation of an iPhone app to iPad. You still should be able to create a universal app for both iPhone and iPad and then re-create your UI based on whether you are running on one device or the other.
Specifically, you could:
Create an XCode project for a universal app (armv6 and armv7, targeting iPad and iPhone) and import there your existing project (source, resources, settings).
1b. (you could modify your existing project, but this could be trickier to do correctly.)
add icons and default images as per iPad guidelines in addition to those you have for iPhone;
As to the rest, you could follow a similar approach to the one highlighted here for Xibs:
test for iPad:
+(Bool)isIpad{
return ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
}
translate image name before loading:
+(NSString*)properImageFileName:(NSString*)imageName {
if ([xxxx isIpad]) {
return [NSString stringWithFormat:#"ipad_%#", imageName];
} else {
return imageName;
}
}
Thus, if you are on iPhone, image names are not changed and will follow the iPhone convention for retina display; if you are on iPad, you change the name on the fly and use the right image. (of course, you can use the convention you prefer to identify iPad images).
This should make it pretty trivial, but keep in mind the size toll that having all the images in your universal app tolls.