Auto-Layout vertical spacing issue - ios

I'm having some issues with auto-layout where it would show different spacing in IB than in runtime.
Here's the screenshot of IB:
As you can see, the big numbers don't have any padding at the top and bottom.
But when run, it looks like this:
Am I missing something?
BTW, I come from Android dev, and looking at all those constraints I feel like I'm either missing a simpler solution or iOS UI dev is a real pain compared to Android.

"I'm either missing a simpler solution or iOS UI dev is a real pain compared to Android"
You're missing a simpler solution. Auto-layout can be frustrating, until you get the hang of it. After that, it makes things sooooo much easier than it used to be.
Here is a version of your table cell, where the spacing stays consistent between IB and runtime. And, it uses UITableViewAutomaticDimension
As you can see, it's much simpler than what you had. If you tell me if you're using Objective-C or Swift (2.2? 3.0?) Xcode 7 or 8, I'll be happy to make the files available...

Related

How to get iOS app to work on all iPhones? (Constraints)

I am fairly new to developing for iOS. I have a fully functioning program written in Swift and the UI was created in the scene builder on Xcode. I created an app for my work to simplify closing out the registers and other financial aspects. The app is complete and works perfectly, but was designed on the iPhoneX. The problem is that only a few of the employees have an iPhoneX, but they all have some kind of iPhone. I have tried setting up constraints but it never works. Ive tried scaling restraints and position restraints but I can't get the layout to look right on any other phone, and when I add the constraints it affects the view on the iPhoneX as well and doesn't look good on any iPhone. I need help getting this to work on all iPhones. I would like it to look and act the exact same regardless of the size of the phone, basically just scaled down. There are a lot of things on the screen and I can't figure out how to do this. Please help!!!
I have been working on this for a long time and I really need help. Please let me know if I need to clarify anything. I have posted links to some pictures of my UI so you have an idea of whats going on.
Constraints I tried adding, although I have played around with some other options.
Here's what it looks like on the iPhoneX, this is how I want it to look.
What it looks like on iPhoneSE (with constraints).
One thing I noticed in your Xcode project that none of your features are in UIView. Without it, it will be quite challenging and somewhat always different results. In theory, if you use AutoLayout features correctly it should work without UIView, but they make life so much easier. This is something I learned the hard way at the beginning of my iOS development. First set up your UIViews without any content inside it, give them some background colour to differentiate, once they are working on all devices. You can pin your features to superviews with no difficulty.
Since you have a repetitive features, you could also consider using Stack Views. You don't have complicated features, so as long as AutoLayout is set up correctly you should have no problems seeing it ok on all devices

Best approach at designing an iOS frontend

I am designing my first iOS app at the moment. Every view of the app needs to be available in portrait aswell landscape. Also all iPhone versions need to be supporrted.
As someone always working with windows and never owning any apple product it was a pain in the ass getting started but slowly things seem to work out. But before the whole design approach takes a wrong direction I rather ask here:
What I want to do is have constraints based on multipliers as much
as possible.
I will try to avoid constant values as much as possible since from
my understanding they arent scaling. I read that you can change them
programmatically but if possible I want to stay in the designer for
frontend related stuff.
Since the multiplier cant be changed based on the current size class
I plan to have a set of constraints for all kind of portrait size
classes and another one for landscape (using installed feature of
xcode)
To up and downscale labels and textviews I want to have a height
constraint to the superview with a very tiny multiplier (will
probably be complicated to keep all textviews the same height when
there are different parents across them?)
In theory this should produce views which up and downscale well and look the same on all kind of iPhone screens. Now I am curious what more experienced iOS designers think about my "plan":
Do you have different approaches?
Is there any book/tutorial/page you can suggest?
Thanks in advance! :)

Simple IOS Layout

I have been trying to do this layout for a few days now and cannot do it. I have no code as I have been only using Storyboard.
In my Android version I simply used a weighted LinearLayout where my title was 20% my relative layout was 60% and my custom object was 20%.
I cannot replicate this in IOS. Everything I try fails. I have tried everything and have tried using StackViews, EqualHeight constraints with multipliers and everything does not work. Most of the time nothing even happens and it just looks the same. Can someone please help me? I am so frustrated I am considering abandoning XCode in total and coding my app in React Native.
It's not really clear what you're asking. But if you want to use storyboards, it's pretty easy with XCode. You can set your layout visually, then simply use the "auto-resolve" feature (little triangle inside of bars on bottom right above the console) to: 1) "clear constraints" and then 2) "reset to suggested constraints". This is a fast and crude method that should more than enough to get started.

question about using AutoLayout in an application with many animations - past failure; has anything changed

We have a utility app that has like 10 major animations for manipulating the UI. A new developer suggested that we convert from managing position in code to using AutoLayout. We have tried this once before and it just really didn't work (and all constraints in code) and the constraints would break. Are we being Luddites by not adopting AutoLayout or are major projects not using it?
Has anything significant changed where this would be easier from 18 months ago? My feeling is that if we don't absolutely need it, we're better off staying just manipulating frames in code.
Using autolayout is necessary because the screen sizes vary so much. Trying to modify layout constraints manually to mimic what you currently have can be a HUGE head ache.
A solution is to move the animation code into storyboards (well as much as possible anyway). The code you have to maintain will most likely shrink dramatically from pre-autolayout to using autolayout (depending on the animation type). Here's a tutorial

Should I use auto layout in Xcode 6 or should I prefer using separate storyboards for all iOS devices

I am having real difficult time using auto layout as when I sometimes change the views, it becomes a real mess with the already assigned constraints. So should I really give more time to myself learning auto layout or should I just go with multiple storyboards as it takes a bit of time but ultimately makes it easier for us to change the design easily in future.
From my learning,
I felt the same because its hard to learn and understand AutoLayout for first time. Here is the lot of advantages using
AutoLayout Advantages
Future iOS Versions going to support auto layout
It will save you lot of your time when ever new version of OS get released
Using Multiple StoryBoard
You need to maintain for each screen which is clearly hassle if you want to change anything in your View.
It will eat lot of your time to fixing
and much more
Spend little time in AutoLayout. Its not that hard to learn.
Auto Layout
Size Class Explanation
I am sure above link will help for all beginners.
The practice we are using is always splitting the Storyboards into smaller chunks, because they get ridiculously big and hard to work on. But we are not splitting them for different devices, but feature-wise. For example the Onboarding process has a separate Storyboard.
But we are always using auto-layout and iOS 8 size classes to support different devices. In some cases we even code constraints in code.
So learn Auto-layout sooner rather than later, it will save you time on multiple occasions.
In new Xcode you can find Size Classes in Storyboard which helps to manage various screen sizes. On beginning it seems to be hard but after little time it will save you lots of work.
I suggest to start here: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/_index.html
It is important to create proper constraint. Set on view size class: Any x Any and then you can create constraints automatically, clicking Editor -> Resolve Autolayout Issues -> Reset To suggested Constraints or use shortcut: Command + Option + Shift + "=" while object in storyboard is selected. Honestly, it doesn't work properly in each case, sometimes you just have to set it manually.
Summarizing it's worth lo learn AutoLayout and make all screen sizes in one Storyboard.

Resources