简体   繁体   English

IOS Storyboard将每个子视图约束到屏幕底部

[英]IOS Storyboard Constraining Every Subview to bottom of screen

This seems like it should be very simple, but I am having a terrible time trying to get every subview (they act like menu bars) constrained to the bottom of the parent view in the IOS storyboard. 这看起来应该非常简单,但我正在尝试将每个子视图(它们像菜单栏一样)约束到IOS故事板中父视图的底部。

There seems to be automatic constraints placed between the subviews that make them override the constraint I'm trying to set. 在子视图之间似乎存在自动约束,这使得它们覆盖了我试图设置的约束。 I try to take these off, and then place the new constraints, but nothing seem to work as I loop over trying to reset constraints, over and over and over... 我试图取消这些,然后放置新的约束,但似乎没有任何工作,因为我试图重置约束,一遍又一遍地循环...

It should be very simple, set all of the uiviews to a particular width and length and set the distance between the bottom of the superview to be equal to 0. That's it. 它应该非常简单,将所有uiviews设置为特定的宽度和长度,并将superview底部之间的距离设置为等于0.就是这样。

The secret to happy constraint editing in interface builder is simple: 在界面构建器中快乐约束编辑的秘诀很简单:

  • Don't do it 不要这样做

If that isn't possible, then: 如果那是不可能的,那么:

  • Create your own constraints before trying to delete the system ones 尝试删除系统约束之前创建自己的约束
  • Make judicious use of the pinning menu and editing constraints in the inspector 明智地使用检查器中的固定菜单和编辑约束
  • Don't drag and drop your views after you've added them - this causes interface builder to discard all constraints and set you up with a new set of "best guess" system constraints. 在添加视图后不要拖放视图 - 这会导致界面构建器放弃所有约束并为您设置一组新的“最佳猜测”系统约束。

I've written more about this here but that's the gist of it. 我在这里写了更多关于这个的内容但这是它的要点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM