Can we develop single app for iPhone and iPad - iphone

I’m new to iOS development and currently developing an app for iPhone and iPad.
My question is can we develop single app that can run on both iPhone and iPad which match their different screen sizes or resolutions . Or do I need to compile 2 different applications that match the different screen sizes or resolutions in iPad and iPhone?
Thanks.

Yes we can! Universal app is the solution!
Read this blog : http://www.kotancode.com/2011/04/05/ios-universal-apps/

We can develop single app to achieve this. Just select Device family as universal while creating new project. You will get option to prepare different Xib's for iphone and ipad. In code, you can either check for the device or use proper naming while allocating it.
For example,
For iphone -
oneViewController *oneView = [[oneViewController alloc]initWithNibName:#"oneViewController" bundle:nil] autorelease];
For ipad - You can just use "oneViewController~ipad" as xib name. This will automatically load xib for ipad.

you can make one universal app for both iPhone and iPad. Create different layout for both either using storyboard or nib files.

Firstly you don't need to compile 2 different applications that match the different screen sizes or resolutions in iPad and iPhone. There are already universal app in AppStore.
Try this:Universal-iOS-App-Template And this question:iPad/iPhone universal app

Related

how to convert ipad version app to iphone version?

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

Objective C - One storyboard for iPad and iPhone

I just want to know if it is possible for an iPad and iPhone application to share the same storyboard?
I currently have 2 storyboards, one for iPad and one for iPhone. Is it possible to have both devices running form the same storyboard?
Regards,
EZFrag
If your iPhone and iPad has same views, then this is possible, the views you create in your iPhone will stretch to fill the iPad screen, however this is not recommended since iPad has bigger screen you should create different views with different view arrangements and structure for both the iPad and the iPhone
To set the same story board for the iPad and iPhone check the screen shot
Using the XCode6 Size Classes you can officially have the same Storyboard used for both the iPhone (all resolutions) and the iPad, saving you from keeping two files up to date.
The resulting storyboard is compatible with iOS7+.
Read more about this here: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html#//apple_ref/doc/uid/TP40014436-CH6-SW1
Use size classes to enable a storyboard or xib file to work with all available screen sizes. This enables the user interface of your app to work on any iOS device.

Problems with Universal iPhone/ipad app build

I have created a Universal (iPhone/ipad) application .I have created separate Xib designs for iPhone and iPad both works well. When i build the app it should give a single .APP(build).I installed in iPhone and iPad tested correctly.
Now i want to give a two separate builds (for user to test), one for iPhone and another one for iPad.So in project settings i changed a target device family (iPhone/ipad -> into iPhone) and (iPhone/ipad -> into iPad). So it gives two separate builds.One for iPhone and another one for iPad.
My problem is when i build with iPhone(as target device family) and installed in iPad means it loads a iPad design not an iPhone design.What could be the mistake i did here ? I search a lot and could not find any solution.
If any one did like this? or do it for me?(testing)
Thanks in advance.....
It's because (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) if you run iPhone-designed app on iPad. And thats why iPad version of xib file is selected. So you need to attach correct .xib file manually, or exclude iPad version of it from iPhone resources.
The tester can install the same build in both iPhone and iPad. The concept of universal build is that, the same app will work on both iPad and iPhone.

Converting an iPhone app to an iPad app in XCode 4

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

can i release an app which targets iPhone for the iPad?

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.