Creating an iPhone- and iPad-compatible app with a storyboard - ios

I am trying to create an iPhone and iPad compatible app.
Is there any good tutorial and example I can follow?
Can I create one view or storyboard for each view and use it for iPhone and iPad?
If I use a storyboard, can I do something like this:
If it's iPhone, use this storyboard design, if iPad, use the other storyboard design.
Or do I need to create a new view or storyboard for iPad and one for iPhone?
I have no clue how to start at this moment.

You only need one storyboard to build an interface that is compatible with both iPad and iPhone models.
Apple is now encouraging developers to embrace Adaptive User Interfaces. As their guide states, "With the latest advancements with View Controllers in iOS 8 and Auto Layout in Xcode, it’s now even easier for you to adapt your user interface to context and different sized devices". In other words, you only need a single storyboard for all iOS devices, also known as a "Universal" storyboard.
This tutorial should get you started with Universal Storyboards and adaptive layout.

Related

Size classes and Auto Layout confusion with multiple devices

I created my first app without using size classes and auto layout. Now i'll be making a 2nd app but i'll use size classes+auto layout. So pardon my confusion.
In Xcode's, Assistant Editor preview, I will use all the device sizes for the preview, all iPhones and iPad, iPad PRO.
My understanding is I can use 1 Main.Storyboard for all the storyboards of all devices with the preview storyboards.
However, when it comes to coding, can I also use just 1 view controller.h and view controller.m file for all devices?
Of course, if you can use a single storyboard for all the devices, what makes you think you would not be able to use a single view controller?

is it possible to design view for iPad without autolayout?

I have developed app without autolayout for iPhone. Now I need that app for iPad also. Is it possible to create it without autolayout?
yes, you have to create App directly then select iPad.
and using Auto Resize ,you can directly develop app for iPad only.
I have attached few Screen shot, may be helpful to you.
Create new project, using XIB .
I don't recommend that (see comment of #Nimit Parekh).
You can use Sized classes to avoid having 2 separate Storyboards - one for iPhone and other for iPad. There is a good tutorial.
Second option is to have 2 storyboards. You only need to link all outlets from the 1st storyboard to the second. You have to check not to miss something, otherwise you can get exceptions in iPad.
The 3rd option is manually (from the code) to manage layout for iPad - but this will create a lot of specific code for iPad only (you have to check what type is your device and split code) - this is not recommended.
Take into account that Autolayout is more easy to apply on iPad (from my point of view) because of equal withd / height ratio for iPad - it is the same up to now. Not like in iPhone.

What is the best practice when making a storyboard for iPhone and iPad?

I'm making an app that would run on iPad and iPhone but only in landscape mode. The first app that I made was only for iPhone using one storyboard and hAny wAny size classes.
What are the good practices when designing an app for iPhone and iPad, regarding usage of storyboards and size classes?
Should I make 2 storyboards for each one of them? If so, what would the size classes be?
You Should use 2 Storyboards. One for iPhone and another for iPod.
No need to create two storyboard, you can design an app using auto layout.
http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1
Use Size classes. Start from wAny and hAny. Make appropriate changes for each device switching to different sizes. Using container views will make it more handy.
Single storyboard should be sufficient for both iPhone and iPad. A
storyboard specific to a separate module / User story is preferred.

Do I still need two Storyboard files to manage different devices now with Universal Storyboards?

I have an iPad only app that I'm switching to support iPhone as well. Not going well so far, the project was created before universal storyboards. When I run it on the iPhone, it sticks with the good ol' iPad size. Should I delete my storyboard and add a Universal one, or create separate Xib's / Storyboard's to support iPhone's?
I don't think you need to create separate xib or storyboard to support iPhone.
You can enable auto layout and size classes in your storyboard. Auto layout helps you layout your views based on constraints while size classes helps you check whether the view is running in iPad or iPhone, as well as the device orientation.
You can then layout your screens based on different size classes.
Please check WWDC video Building Adaptive Apps with UIKit for more information.
You can use a second storyboard but in my opinion it is easier to generate all the objects in code. Then you can use values like this: self.view.frame.size.width/2 to center it on the x-axis on every device. And you don't need a storyboard for every screen size.

Principles for creating universal app

I am in process of creating a new universal application.
Would it be "bad" or against guidelines to create separate classes to control the iPad version?
I am using a tabbarcontroller for the iPhone version and a splitview for the iPad version.
It seems easier in my case to create new classes to handle all the iPad stuff.
Thank you for your time!
Nope, not bad or against guidelines at all.
In my own universal apps, I use separate XIB's for iPad versus iPhone interfaces. And sometimes different (or additional) classes for iPads as well.
Probably one of the more important things is that the functionality is roughly the same between iPad & iPhone versions... will the tab bar view do the same thing the split view do, for example?

Resources