I'm really having tough time setting my layout right for all iPhone sizes. I have five buttons and I want them to be visible correctly for all iPhone sizes, see the screenshot. I've tried many constraints but no success. Following are my questions.
What constraints do I need to add to these buttons to fit all iPhone screen sizes?
When I change "wAny hAny" to some other settings, all my UI controls vanish. What can be the possible reason?
Do I have to start in "Any Width | Any Height" configuration to design my app for all screen sizes?
3: it's a must: start of with Any x Any
2: other then Any x Any can have custom constraint settings (like bigger Font or const. for iPad). If things change when you switch to other then Any x Any then A: your constraints are messed up B: you have custom settings (which I doubt). Neither case I would recommend to start from Any x Any , remove all contraints, and start all over until Any x Any works! then move on to detailed customization.
1: use "greater or equal" relationship between the buttons horizontally. Add fix constraints if needed on the two sides.
Remove all warnings, read about it for two weeks :)
Related
Having a hard time finding an answer for this.
The storyboard doesn't have the "view as" option for my iphone (xs max), so the screen on the storyboard always ends up butchered when i launch the app (the labels dont end up as they're seen in the swift storyboard). Am i missing something really simple?
It seems I don't have the XS Max as a selectable "view as" option either. However, the reason you're having this issue is because of something called Autolayout. Autolayout allows you to set constraints for all your UI elements, keeping the UI's integrity across multiple devices. If you set constraints for each element on the screen, you'll solve this issue.
If you're unfamiliar w/Autolayout, learn more here
Preferably using storyboard.
This is another one of those things you would imagine to be so simple it shouldn't be thought of.
The only way i know how to add a constraint to a subview is in storyboard i click on the constraint button on bottom left. However, the only way to set a constraint is by constants which make no sense because the resolution of apple devices change. So if you were to put a constant constraint of one subview to 50 for example on an iPhone 5s and everything looks good, on an iPad everything is way off which thinner and/or thicker spaces.
You would think percentage would be the main way to go and constants should be more difficult to access.
Anyways please let me know how to do this. In the answers found online i only saw ways to do it in code but i would like to keep it all in story board if possible.
Thanks!
I just started making an app, and I have done a lot but I was not working with auto-layout. My whole app is in landscape mode, and I want it to work on all iPhone's. I now designed it for the iPhone 5, but when I open it on iPhone 6, there is a lot of whitespace. Is there a button to automatically resize everything? Or must I add auto layout and do every designing bit again?
Unfortunately you're probably going to have to layout everything again with auto-layout. A way to expedite your process would be converting the storyboard to auto-layout and then selecting "Reset to Suggested Constraints". You can access this option by pressing the small triangle icon in the bottom left.
Despite this, you probably will need to update a lot of the constraints manually. But this should give you a step in the right direction.
Have you tried Size Classes? Or Stack Views?
Size classes:
Apple documentation # https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Size-ClassSpecificLayout.html
Apple documentation on Stack Views #
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/LayoutUsingStackViews.html#//apple_ref/doc/uid/TP40010853-CH11-SW1
A good tutorial on "Stack Views":
https://www.raywenderlich.com/114552/uistackview-tutorial-introducing-stack-views
I am trying to make my app's storyboard universal for all Apple devices. I am having an issue with auto layout for some of my views. I am considering making a storyboard for each device since I think it will look better in the end, since I would be able to size my fonts and buttons differently for each type of screen.
What would you guys recommend I do?
Thanks
A good approach would be to use autolayouts and size classes. This approach would allow you to create only single storyboard for both iPhone and iPad. And you can easily size your fonts for different devices and also make buttons/views position/size differently for different screen sizes using size classes.
You should use size classes in which "any width , any height " is best for all layouts .
AFIK you can't just use size classes to determine the screen size and then set font sizes based on that. As can be seen when you edit in Storyboards, you can set the font sizes for specific size classes eg. compact, regular etc. but not iPhone 5, 6 or 6+. If you are wanting different font sizes for different screen sizes you could use UIAppearance to style your text elements in a centralised way or create IBOutlets to the UI elements and set the font size or other properties as required. With either of these you may still need to check the screen size with something like this:
switch UIScreen.mainScreen().bounds.size.width{
case kIphone6PlusWidth:
label.font = label.font.fontWithSize(20)
case kIphone6Width:
label.font = label.font.fontWithSize(18)
default:
label.font = label.font.fontWithSize(14)
}
Alternatively, separate storyboards for each will give you customisability but will lead to a fair amount of duplication with laying out the UI elements in different storyboards.
I've been using the constraints for all objects to be aligned with each of the different screen sizes, but I want to manually set each one.
How can I manually adjust the size and location of objects on each screen size?
You can create storyboards for different sizes and load them; you can also set outlets for those constraints and set their constants.
Nevertheless, I would advise you to keep them all in one storyboard and try to adapt the autolayout to make it work for every size.
Tip: add a another navigation tab and select preview mode on this one (on storyboard). This way you will be able to see how the constraints behave in different sizes.