I'm implementing a lock-screen page in iOS.
But the design for iPhone 6 requires text on top is pretty large, which causes the bottom in the page is hidden in devices equipped with small resolution screen like iPhone 4.
Do I have to define multiple xib for each device in this situation?
Or make some views smaller programmatically?
Or make some margins smaller programmatically?
Are there any references for this? I'm new to auto-layout.
I would suggest you to use autolayouts. From my understanding your app can be implemented with stack views.
So start with this document,
http://www.appcoda.com/introduction-auto-layout/
and
http://code.tutsplus.com/tutorials/ios-from-scratch-with-swift-auto-layout-basics--cms-25520
Then checkout the apple documentation for further understanding
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/
If the constraints are too confusing, try stack views
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/AutoLayoutWithoutConstraints.html#//apple_ref/doc/uid/TP40010853-CH8-SW1
Creating multiple xibs is not a solution. Make use of autolayouts :)
Related
For a very large ios project with the huge amount of features and complex user interface, would like to have the suggestions for following -
Will it be more easy and convenient if we use different storyboards
for iPhone and iPad Screen sizes as developers used to do a couple of years back when UIStackView was not there?
What are the best practices to achieve the complex UI using storyboards, Auto Layout and also have a maintainable code? Please share your experiences.
Will it be more easy and convenient if we use different storyboards for iPhone and iPad Screen sizes as developers used to do a couple of years back when UIStackView was not there?
Using different types of storyboard / xib will increases your bundle size. So it is not a good idea. Before xcode-7, developers do not have any good choice instead of this. Now you can use auto-layout, it can easily maintain your whole screen.
If your design is something like master-detail (like device setting) then you can use different VC's.
What are the best practices to achieve the complex UI using storyboards, Auto Layout and also have a maintainable code? Please share your experiences.
You can auto-layout, size classes, even vary of traits is more helpful to maintain the designs.
I think it's better to use only storyboard for iPhone and iPad , where you can create constraints in proportional to screen size , and tweak constants with add variations plus using size classes for handling screen variations with adaptive layout
I would advise to use Adaptive Layout with Size Classes and Auto Layout.
On quite a large universal projet, it saved me a lot of time, especially, as you pointed out, since UIStackView!
https://www.raywenderlich.com/162311/adaptive-layout-tutorial-ios-11-getting-started
Using sub storyboards is also a great relief on very large projects.
Having two sets of storyboards is quite painful as you have to duplicate many things. I only use a specific storyboard, when the UI on both platforms is really really different.
I am an enthusiastic beginner in iOS development and I have faced some questions that may occur to many other beginners as well. Please note that I am not asking for opinion or suggestion, instead need some clarification to use the best option that I am offered.
Speaking of designing the apps interface via Swift. We have three options which are : programmatically, StoryBoard or Xib file. The question is, can employ more than one of these three for the same project or even the same page(screen) in my app?
When I am using Storyboard I can drag and drop different objects and use them. How ever I either need to set my own constrains for every single one of them or I can select all and click the set required constrains and they will be all set. But how come although I've defined the constrains my view is not responsive on various devices? Based on my understanding the only way to get the responsive in all the iOS platforms to set the constrains programmatically! Feel free to correct me if I am wrong.
It may not be the best practice but I personally am more fond of back-end comparing to the front end. Is it possible to design all the back-end first and set all the constrains at the very end!?
1.Speaking of designing the apps interface via swift . We have three options which are pragmatically , Story Board or Xib file . The question is can employ more than one of these three for the same project or even the same page(screen) in my app ? ]
You can use storyboard for UI designing and also Xib's also you can use for example if you want design custom alertviews. This is just an example.
2.When I am using storyboard I can drag and drop different objects and use them . How ever I either need to set my own constrains for every single one of them or I can select all and click the set required constrains and they will be all set . But how come although I've defined the constrains my view is not responsive on various devices . (Based on my understanding the only way to get the responsive in all the IOS platforms to set the constrains pragmatically!! Feel free to correct me if I am wrong . )
First understand the Autolayouts in iOS. This is very powerful tool for iOS developers for responsive layout.
We can do Autolayout in either ways i.e., programmatically or Storyboard. But I can suggest for storyboard is better. In Some cases we can use programmatically.
Follow these links:
Autolayout for beginners
Introduction to Autolayout
3.It may not be the practice but I personally am more fond of back-end comparing to the front end . Is it possible to design all the back-end first and set all the constrains at the very end !?!
As per my view, First design responsive UI, Check in all devices. In latest Xcode, We can even check UI in all screens.
Dont use multiple storyboards for every iOS device. Use Autolayouts for desgin UI with single screen in storyboard
New to iOS developing here. Basically I am creating a soundboard app. I have the app essentially working (aka buttons returning sounds).
However my app only looks proper on the iPhone 6. I just have one ViewController in my main storyboard. When I run the simulator for the 4S/5/6+ or iPads, my buttons are pretty much everywhere.
I tried playing with size classes/autolayout through Apple's documentation, but couldn't get it working properly. What's the best (easiest ;) ) route I can follow to have it basically looking the same on ALL devices?
PS: I have one background placed too, I don't mind if it looks different on all devices since it's pretty minimalistic, but if someone can shed some light here too, that would be great.
Thanks!
You have a few options:
1) Continue your plan spending time getting friendly with Auto Layout and Size Classes. This might be difficult at first, but it will really pay off later. You should use the Assistant Editor's Preview mode to let you see iPhone 4, 5 and 6 side-by-side as you work so you can make sure your layouts look great everywhere.
2) Use a component like UIStackView where layouts are automatically adjusted to fit various devices. If your soundboard is as simple as a grid of buttons, you can do that in just a few minutes using a stack view.
3) Use a component like UITableView or UICollectionView where content is designed to scroll. Using this method you design only one sound button of your app (i.e., enough to play one sound) then have iOS replicate that across all the sounds you want. When your interface is presented on a device of a different size iOS will just make the content scroll.
Very roughly, option 1 makes you do all the work; option 2 makes your layout shrink down until it fits the available space; and option 3 makes your layout stay the same size no matter what, but you should expect it to scroll on some devices.
There is no right solution; it's entirely down how you want your app to work.
I have a feeling about iOS development on which I would like to get feedback.
Storyboard / Interface Builder are, at first glance, awesome tools. The truth is that aside quick prototypes and really simple user interface I always feel blocked using them. This question offers probably a good example: how can I use one storyboard for 4" and 3.5" iphone screens with autolayout (ios6 + ios7)?
I am considering to code all my views. Mostly because it will let me implement some logic, like equal spacing of elements. Something that is, AFAIK, impossible to do in a cross device fashion through the GUI tools.
My questions are: Does Storyboard / IB support advanced view layout? How do you usually code your view if you do so: extending UIView / tweaking the controller?
EDIT: the accepted answer link is nice. Interested readers could also look at Apple's Auto Layout Guide relevant example: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/AutoLayoutbyExample/AutoLayoutbyExample.html#//apple_ref/doc/uid/TP40010853-CH5-SW7
http://www.raywenderlich.com/83276/beginning-adaptive-layout-tutorial
Ray gives a decent starting guide on how easy it is to create a single adaptive view now, which has caused me to switch from being completely programmatic.
Previous to iOS 8 it was much harder to build complex layouts using Interface Builder. You were essentially limited to stretching or pinning to edges. Now you can build layouts that adapt to size classes and change their layouts or constraints based on the width and height of your device.
That being said, even in really difficult scenarios that IB can't handle, I still end up building chunks of views in XIBs and then laying out those chunks manually.
TLDR; Interface Builder is going to be helpful 99.9% of the time as long as you know how to use all its features.
I've read around that Apple is hinting to developers at a larger-screen iPhone by pushing developers to use Storyboard and auto-layout. I understand why auto-layout would be useful, to organise items according to screen size, but what do Storyboards have to do with anything?
I may be missing an obvious advantage (in relation to larger screens), so any help would be much appreciated. :)
A. You say that there are some notice from Apple about the larger screen of the iPhone6: This is impossible because Apple doesn't release any information until the date of Keynotes and WWDC.
B. You can or not use Storyboard, and you can or not use AutoLayout: the 2 things are separate because you can also use AutoLayout in nib or programmatically.
C. What developers don't know, is that Storyboard are just a market move. I spoken directly with a my friend engineer in Apple about this and the information is real. The reason is also obvious. Is not the topic to speak about this but you can search on google and you will find a lot of information about the advantages to don't use storyboard.
Yes, storyboard are easy, but are not developer friendly if you think to work in a serious project with a big team. In a team you can use GIT, you can use shared repositories, you can export a part of code with the interface...in all this thing, Storyboard are BAD!
So i encourage developers to DON'T USE storyboard and use at max NIB file, or write the UI directly by code.
There currently doesn't appear to be any advantage to using storyboards versus XIBs or programmatic layout as far as multiple screen sizes are concerned. Auto-layout is definitely advantageous as it allows you to define your interface elements in relation to each other (and the screen), as opposed to using fixed numerical values for location and size. This would allow the UI to then easily adapt to varying screen sizes and aspect ratios.
The only potential reason storyboards could become useful for multiple screen sizes in the future is if Apple adds functionality to them to allow you to define entirely separate views based on device/screen size. So for example, they might make it easy to show a view with an extra sidebar on a larger screen, but show a separate view without the sidebar on a smaller screen (they might make it possible to configure this easily in a storyboard, versus writing a bunch of code to detect the screen size and load the appropriate view programmatically). As of now, though, no such functionality exists, but that could be a potential source of the rumors regarding storyboards being useful for multiple screen sizes.