Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Frame "will be different at run time".... Isn't that the whole point?

Maybe striving for a "warning free" project is futile, but I am nervous enough about Adaptive Layout/ AutoLayout that I am compelled to try and squash these warnings.

I have a uiview that I want to be dynamically sized based on the portrait screen width. I have my app set in the Build Info for Universal, Portrait only (and upside down). I have constrained the uiview the following ways:

  1. Aligned the view's Center to Superview's center X
  2. Made the view's width proportional to the Superview's width
  3. Gave the view an aspect ratio constraint of 1:1
  4. Given the view a vertical constraint to the superview's top

For details please see the screenshot below.

So now I get the warnings about the view's "frame being different at run time", in particular the size and position at runtime versus what is in the canvas. Not sure why Xcode "cares" about the canvas where the class sizes are set to Any height and Any width. I thought the whole point of Adaptive layout is that sizes and positions are resolved at runtime based on the devices screen size and orientation.

If I breakdown and let Xcode "Update frames"... yes the warning goes away, but with the super large views it is virtually impossible to work graphically in the tiny canvas in a WYSIWIG fashion. Any solution here to getting rid of the warnings without creating oversized views that make working inside the canvas nearly impossible?

Canvas screenshot

like image 730
Electro-Bunny Avatar asked Sep 23 '15 13:09

Electro-Bunny


3 Answers

To get rid of the warning, and let the constraints place the views "correctly", just select the view that is giving the warning, press the little triangle thing in the bottom right corner of the storyboard: enter image description here

And then select "Update frames" for "All Views in Container"

(I wish there was some way of doing this to a whole storyboard. At least I haven't found it)

like image 175
ullstrm Avatar answered Oct 16 '22 00:10

ullstrm


Select a view and press

  • Option + Command + =

This will update the frame size. Repeat for all offending views. It doesn't take that long, especially if you find them by clicking on the error messages.

Thanks to this answer for the idea.


Notes

After updating to Xcode 8, and choosing some View as device, I was getting this error. The menu is different than in Xcode 7, so @Spoek's answer was no longer working. Also clicking Update or Reset was not working for me.

enter image description here

Update

Update Frames now has its own button. That's why I missed it before.

enter image description here

like image 23
Suragch Avatar answered Oct 16 '22 01:10

Suragch


You can change simulated metrics size for example to 4-inch iPhone!

enter image description here

Or Freeform and then change the size to what suits you best.

enter image description here

like image 8
Aleš Oskar Kocur Avatar answered Oct 16 '22 01:10

Aleš Oskar Kocur