This relates to my earlier question at http://forums.bignerdranch.com/viewtopic.php?f=623&t=11283.
I followed instructions up through page 67 (which is where we align the text field with 4 labels). I have two different macs that get different results. Both are running OS X 10.11.4 and Xcode 7.3. Both seem to be in error also.
There are 5 warnings for frames being different at run time. The problem is that auto layout is not correctly centering the frames, although Xcode is aware of it. The text field has its x at 176 and its width at 250. As far as I can tell, the width of the view is 600. So the x coordinate (which seems to the position of the top left of the frame) should be (600 - 250)/2 = 175. So, I agree the label is out of position. But this is after updating all frames in the container according to the constraints which should have all frames centered horizontally in the container. When I select the triangle in auto layout to update the frames, the warnings go away. Furthermore, the x for the text field correctly becomes 175. But, the “is really” label then gets out of position by having its x move from 271 to 270 (its width is 58, its correct x should be (600 - 58)/2 = 271).
- So why does Xcode give different results after updating all frames in the container (when applying the lest set of constraints) versus updating all frames through the triangle icon in auto layout. Should you always update twice?
- Why is Xcode not giving a warning about the “is really” label now being out of place? Why did Xcode move this label at all? It was already in the right place.
I get no warnings.
But, something else really weird happens. The x for the text field is actually incorrect – it shows the value 175.5. It should be 175. When I open that same file (via iCloud Drive) on the macbook pro, the file opens up with the x as 176. When I open that file back up on the macbook, the x remains at 176 (the file gets saved back to iCloud drive that way). Along with other experiments, the macbook pro doesn’t allow for non integer values for the position, but the macbook allows for a .5 but not other decimal amounts.
3. What could be causing these differences with the same operating system and same version of Xcode.
If a frame has an odd width, and since the container has even width (600), why don’t we allow for .5 in the x position? If, say, the width is 101, then the x position should really be at (600 - 101)/2 = 249.5. Given the inconsistencies in my computers, I am not sure what people usually accept for centering. Do people normally prefer even widths to avoid this issue?
As I am changing values of the struts or the widths in auto layout, the numbers that I type in get reverted back to the original value as I type a number in a different strut or width box. This happens almost every time. I have to triple check my inputs because they keep getting changed, and this happens on both my macs. Is anybody else having this problem? It is very frustrating to keep re-entering numbers because Xcode changes them back.
Thanks for any help on these matters.