Add ipad interface to iphone app - ios

I have been watching some of the solutions for this problem. There's any solution that not implies changing the code? I have seen solutions like put an if/else with the device type every time I load a ViewController. Theres no a way with xcode that this step is automaticaly done?

If you are using storyboards in the info.plist you can choose by configuration each storyboard, one for iPad and other for iPhone/iPod touch
If you are using xibs you'l need to change it programmatically using ifs and elses

I found a better method to include my iPad Xib in my project. I only have to add ~iPad at the end of the name of my xib. If I have myxib.xib I create a new xib named myxib~iPad.xib and when I run it on my ipad it takes automatically the correct file!

Related

XIB files still used in XCode and For IOS Development

Can someone explain if there is still any use for nib or xib files in iOS development these days? Are xib files even still supported in XCode?
If you wanted to create a new app and/or multiple views in those apps in a non-programmatic way you would simply use Storyboard now. Am I thinking about this correctly?
I use xibs all the time for common cells and views shared between different views. You can't do that with a storyboard.

Convert only iPhone App to Universal App in Xcode 7.2

I followed a tutorial at Udacity to create an iPhone app and I am not only able to run it on an iPhone as I can in an iPad, that's fine. Nevertheless, the screen looks weird on an iPad. In my storyboard, if it is selected "compact,any" and if I changed it to "any, any" it should work, I think, but the elements in the "company, any" format do not come automatically.
I looked it up on google and found http://pinkstone.co.uk/how-to-convert-your-iphone-storyboard-into-an-ipad-storyboard/ - but this is for Xcode 6. I followed the steps:
change from iPhone to Universal in the project settings
duplicate storyboard file using Finder
Add new storyboard file to project
He says to use a button called "Apply Retina 3.5-inch Form Factor" whose icon looks like a person, but it is does not appear in Xcode 7.2. I think that was changed to the "any,any" options that appear on the bottom.
Change part of xml code of storyboard from targetRuntime="iOS.CocoaTouch" to targetRuntime="iOS.CocoaTouch.iPad"
The steps below just made "compact,any" to "any,any" in the new file but with no buttons, views or labels of the "compact,any". Is there a way to do that? I tried copying and pasting also... but it didn't work quite well somehow... maybe I did it wrong.
I am also wondering if I do need to create a new storyboard file. It seems like the "compact,any" is somehow independent of "any,any" and the same file would work for iPhone and iPad.
I am using only Swift for the development language, although I don't think this is relevant for the layout.
That's what I have thought regarding the question.
Answer to your question: You have to create them for each size class, individually.
Explanation: Your constraints and items in your storyboard are created for a custom size class. You cannot just "copy" your constraints from one size class (compact, any) to another (any, any).
Your question title isn't accurate- you're not asking how to "convert" an app from iPhone to Universal (which means it can be used on iPhone and iPad). You've done that already- in your project settings, so it is now "converted" to be a universal app (even though it's useless to you on an iPad, it is still "supported")- and you've answered your own question.
What you're asking (I think) is how to copy your elements and constraints to another size class, which you can't just "copy". What your question should be is this:
"Convert storyboard views from (compact,any) size class to (any,any) size class" to which there is no easy way- it must be done manually.
Your question is a potential duplicate of many others I found. Here is a related question that has an answer that might help you.

iOS - Localizing StoryBoard file

I've heard arguments on localizing a StoryBoard file (the way apple recommends - might) not be a good idea. The recommended way is to highlight storyboard in the project navigation and then localize it by clicking a language in the file inspector.
Here is the other way suggested: Remove all strings from the storyboard and in the ViewController file itself load the localized Strings per UI element. The argument for this is that multiple storyboard files are created per localization and the UI constraints are sometimes not kept. You end up with localized storyboards that have different UI constraints. Thus the storyboards are not identical in layout. Can anyone verify if this is the case?
I have a task to localize a few storyboards and want to know all your ideas and best approach ? BTW not all my layouts that i have inherited from other developers are auto-layout.
It seems in the previous version of xcode below xcode 6 it duplicates storyboards when localizing them. In the newer version of xcode it does not duplicate the storyboard. Instead it creates a text localization file and keeps just one storyboard. You can localize the storyboard the same way as you localize any file from the file inspector.

Make an application work on both iPhone and iPad

I would like to make it so that my iPhone app also works on iPad.
If I run it using the iPad simulator it does work, but the app doesn't show up on the iPad app store, and looks really weird.
Is it possible to create another .xib file for the iPad? I know how to add a new iPad .xib file, yet I don't know how to actually change the RootViewController.xib to RootViewController_iPad.xib if the device being used is an iPad.
I already have code for finding out if the device is an iPad, and I don't want to use auto-layout, because I would like to add different things to the view if they are using an iPad (such as using different images).
I would like to make it so that my iOS applications look good on both iPhone and iPad, and have a separate .xib files for each. Is it possible to change the default .xib file from RootViewController to RootViewController_iPad?
In order to make an application work in both iPhone & iPad then need to follow below steps.
Before create an project please select universal in device section.
In application: didFinishLaunchingWithOptions: put a condition to check the device.
If the device is iPad then load the iPad screen and if the device is iPhone then load the iPhone screen.
Make sure follow the MVC pattern, So that it is easy to populate the data in both the screens.
#class has no effect on outlets or actions it only tells the compiler that there is a class with the name that follows, no information about properties, or methods is included.
If you want to have a xib for the iPad don't create a new class for it, just create a new xib and set the file's owner to be the same as the what owns iPhone xib. You then need to add a check in application: didFinishLaunchingWithOptions: to load the correct xib.
The best option though is to tell Xcode you want a universal app when you create the project.
The key point here is that it must be a UNIVERSAL application. Its a setting when you set the app up for the 1st time. You will end up with 2 UI's (story boards or xib files).
You will have to create 2 seperate UI's for ipad and iphone. You may be able to use the main class itself for most of the code but then you have to basically put code that says
if its iphone.....
if its ipad ......

Different XIB files for iPhone 5 automatically

I am updating my app to support the new iPhone 5.
I was wondering if there's any sort of way that you can create a different XIB file for the iPhone 5 that will load automatically, like when images with "#2x" in the end are loaded automatically when an iPhone 4 is used, without having to make any changes to the code itself.
Thanks!
As I know, there is no simple way to load correct xib for iPhone5 without extra code. However, i can suggest this simple class for detecting iPhone5. In addition, there also is a category for selecting correct image for iPhone5 here. You can do the same for initWithNibName:bundle: method.

Resources