jayhu93 / Tip-Calculator

0 stars 0 forks source link

Error is produced when running on my iPhone SE #1

Open regnerjr opened 7 years ago

regnerjr commented 7 years ago

When running this on the iPhoneSE simulator I see this error printed in the console.

2017-07-30 09:49:23.912834-0700 Tip[73649:6181748] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x610000099b40 UIView:0x7fd0e4709850.width == 343   (active)>",
    "<NSLayoutConstraint:0x61000009ab80 UIView:0x7fd0e4705140.leadingMargin == UIView:0x7fd0e4709850.leading   (active)>",
    "<NSLayoutConstraint:0x61000009abd0 UIView:0x7fd0e4705140.trailingMargin == UIView:0x7fd0e4709850.trailing   (active)>",
    "<NSLayoutConstraint:0x60800009a310 'UIView-Encapsulated-Layout-Width' UIView:0x7fd0e4705140.width == 320   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x610000099b40 UIView:0x7fd0e4709850.width == 343   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

You can see it references some NSLayoutConstraint with an explicit width of "343" which is broken.

A little digging shows that it is this "Separator View" screen shot 2017-07-30 at 9 52 12 am

Suggested Fix

Remove Explicit width constraint from the "separator view", it is already fully constrained because it has left and right margins, as well as top and bottom. Note with a separator view like this it is one of the places where I will recommend a fixed height constraint, but you already have one of them.

main_storyboard

Other Minor Problems

Fixed width on labels? What if you app is localized, or the font changes or the users chooses a larger default font? Truncation city. 😜

main_storyboard

Perhaps, an Equal Width constraint across all of them to keep uniform?

regnerjr commented 7 years ago

Also I think you're awesome! Just wanted to you to know that I care about you. And I care about the flexibility of your layouts.

jayhu93 commented 7 years ago

@regnerjr awww, I am feeling loved! hahaha! yes the width is not necessary as I setting leading and trailing constraints. Thank you! 👍