Why are my storyboard views not iPhone-shaped? - ios

I am building an iPhone app, and the storyboard looks like this:
Notice that the views within the storyboard are awkwardly square. I wasn't sure what caused this so I just went with it.
I set my app as iPhone-only and portrait-only.
When I build the app on my phone though, parts of the view are off the screen, because my phone isn't shaped like the interfaces that I am building.
Anyone know how to fix this?

In Xcode 6 Viewcontroller sized to 600*600 size, its for Auto layout and size classes. You can disable this feature by unchecking autolayout and size classes in the File inspector of storyboard (refer image). If you disable autolayout you can see your storyboard viewcontrollers sized to iphone.

It is Universal Storyboard.
Apple wants developer to create apps with Adaptive Layout
The introduction of Adaptive Layout in iOS 8 is a huge paradigm shift for iOS app designers. When designing your app, you can now create a single layout, which works on all current iOS 8 devices – without crufty platform-specific code.
This tutorial serves as your introduction to Adaptive Layout. You’ll learn about universal storyboards, size classes, layout and font customizations and the ultra-useful Preview Assistant Editor.
--Edit--
If you want to fix the size of storyboard you can adjust width and height.

Related

How do I adjust my layout?

I am moving from Android to IOS, and am following this tutorial. The problem is that my layout is not adaptive, as should be the default. The tutorial shows the layout to be like so:
However, my layout is not adaptive (universal) for both iPad and iPhone, and the UI is only that of an iPhone:
I searched a lot on why my layout is not universal (it should be by default), and most of the results said I need to enable Size Classes.
For me, however, the option to enable Size Classes isn't even there, I have the options:
Use Auto Layout
Use trait variations
Use as launch screen
How do I make my storyboard adaptive and enable Size Classes?
Thanks,
Ruchir
I think your UI is adaptive, it's just that in Xcode 8 the storyboard shows the UI in whatever device you have selected. If you look at the bottom of your screen in storyboard view it's says iPhone 6s, click that and you can select to view as a different device (iPad included). So even though it doesn't look like it, it should be adaptive.
As a side note size classes are only for if you want the UI to be different between devices, not adaptive.

porting iPad app to iPhone using one storyboard with one storyboard

i am able to make my iPad app running on iPhone but the iPhone screens doesnt fit all the content in. For example my table view main text is hidden, the buttons are very much spaced from the border. I understand the spacing given in my storyboard files in too big for iPhone screen.
I want to make my app work for iPhone with very minimal changes. I dont want to create a new storyboard and rewrite everything. Please suggest a good way.
Thanks in advance.
You need to make the app Universal, make a single storyboard the main storyboard in both target's project settings and use Autolayout to position your UI elements respective of the device. Look into Size classes to keep your design responsive.

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?

Autolayout(xcode 6,swift)

In I phone 5s simulator its working fine! I have one label,one image view and one button.As you can click on the link and see the picture now so i tell you that I used my image view as a background and the label is in the middle and the button is in the lower middle so i want that to look same in all the devices. i don't know anything about constraints.I am using Xcode 6
https://drive.google.com/file/d/0B2z_d4wEKPEFLV9RNFVlR3A5SFppa0tJT2tiQkQwVVVVTDVz/view?usp=sharing
I suggest you to take a look at this youtube tutorial. I learned how to make the constrains by watching it. The tutorial teaches how to make the similar layout as you required.
Link: https://www.youtube.com/watch?v=RpMzEmF-xZM
Hope this is helpful~
Autolayout is the tool used to make UI look similar across all devices, you should try to learn it if you want to continue to develop IOS apps. The concepts are pretty basic and are used throughout other languages.
This tutorial is useful if you want to create the auto layout using storyboards.
This tutorial is useful if you are making the view programmatically. I tend to use code for auto layout but it is just a preference, storyboards is fairly simple so I would suggest that. If you are going to do it in code a is to forget setting the autoresizing mask into constraints to false. You have to set this property on all the views you want to use auto layout for.
view2.setTranslatesAutoresizingMaskIntoConstraints(false)
Background ImageView
Select Image ->Pin->Uncheck Constraints to margin-> select top,bottom,left,right.
Button
Select Button-> Pin->Uncheck Constraints to margin->select bottom,left,right,Height.
label
Select label->Align->Center horizontally and Center Vertically in Container.
Pin->Width,Height.
If it is working for iPhone 5 but not another layout then this is probably happening.
There are demensions in the centre of the lower tab bar of story boards
There are screen size settings in the story board and regular*regular is the only one that is universal to all orientations and sizes of the ios device. if you set constraints while viewing in regular by compact (landscape for 5.5 inch iPhone) then those constraints will only be apply to 5.5 inch iPhones in landscape and if you tried running on a smaller iPod it would be as if you never set the constraints. the constraints for the 5.5 inch iPhone would not apply to the small iPod
if constraints were made in compact by compact and you were viewing the story board in say regular by compact then you would get an error saying that things are misplace and will not appear in the same at runtime. view the storyboard in the same dimensions that you set the constraints and you should not have an issue.
There is an option to simulate the device you want to run on specifically in storyboard and it can be say only 5.5 inch iPhones or something, whatever device.
go to paul hegarty developing iOS apps with swift on iTunes you if you want to learn more. He is a good source.

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.

Resources