21

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

Electro-Bunny
  • 1,380
  • 2
  • 12
  • 33
  • Following link might help, if anyone trying to get rid of the warning in collection view controller. https://stackoverflow.com/a/49332995/4146319 – Sujananth Mar 17 '18 at 06:01

4 Answers4

25

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)

ullstrm
  • 9,812
  • 7
  • 52
  • 83
  • 1
    Sorry, maybe I was not clear. In my question I had already noted that I could let Xcode fix things with "Update Frames". My question was essentially how to use the limited Canvas real estate after one had "updated frames". I realize there was a bit of whining and moaning that preceded my question :) – Electro-Bunny Sep 23 '15 at 13:51
23

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

Community
  • 1
  • 1
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
  • @RaphaelP. Updating the frames just makes it look like what it would look like on a running device. Updating frames should always be safe. (That is, it doesn't change your constraints.) The only time I have had a problem with it is when I didn't have my constraints set up right, and updating the frames made it so that it was hard to find the views. – Suragch May 17 '17 at 09:36
  • Thanks for pointing out the update frames button. Not sure how I missed that it was there now, but it has really come in handy! – Scooter Jul 15 '18 at 15:20
8

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

Aleš Oskar Kocur
  • 1,381
  • 1
  • 13
  • 29
0

I was getting this error on static tableview cells. I unchecked the Automatic option and the warnings went away

enter image description here

Andrei Erdoss
  • 1,573
  • 1
  • 13
  • 14