Problem setting autosizing in interface builder

久未见 提交于 2019-12-03 01:31:32

I ran into this before and it was incredibly frustrating. It turns out that when you have Simulated User Interface Elements turned on then you can't change the struts and springs like you want.

Go to Attributes tab (Cmd-1) and make sure that Status Bar, Top Bar, Bottom Bar, and Split View are all set to "Unspecified." Then go back to the Size tab (Cmd-3) and you'll be able to click the lines and changes your Struts and Springs. Then finally you can go back to Cmd-1 and turn those simulated elements back on.

I have a simplified answer:

  1. Goto IB
  2. Click on the 'ViewController'
  3. Goto 'Attributes Inspector'
  4. Change 'Size' to 'Freeform' (something other than 'Inferred')

What you have is this:

Change 'size' to 'freeform' & try now!

Now, it works! Go back & change it to 'Inferred' after you have set the Autoresizing masks.

Open Main.storyboard as source (do not forget, it is just an XML file) and replace "autoresizingMask" tag in the View with the following line:

<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!