xcode 自动布局“添加新约束”在界面生成器中不具有交互性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18963537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Auto Layout "Add New Constraints" not interactive in Interface Builder
提问by Ríomhaire
I am updating an application for iOS 7 and have decided to use Auto Layout.
我正在为 iOS 7 更新应用程序并决定使用自动布局。
When I try to add constraints to anyof the elements in the below screenshot :
当我尝试向以下屏幕截图中的任何元素添加约束时:
i.e.View Controller
, Table View
, View
, Table View Section
, Table View Cell
, Content View
, Label
.
即View Controller
, Table View
, View
, Table View Section
, Table View Cell
, Content View
, Label
.
I am unable do to so, as no itemin the Add New Constraints
panel( as seen below ) is interactive.
(Apart from the Update Frames
Item)
我无法做如此,因为没有项目在Add New Constraints
面板(如下图所示)是交互式的。(Update Frames
物品除外)
In my attempts to resolve this issue I have researched that
在我试图解决这个问题时,我研究了
"When using Auto Layout you may no longer set the frame of a view directly. This line either has no effect, or it may directly interfere with what Auto Layout is doing."
“当使用自动布局时,你可能不再直接设置视图的框架。这条线要么没有效果,要么可能直接干扰自动布局正在做的事情。”
also
还
"When setting the contentSize of a scrollview with Auto Layout, the content size is automatically derived from the constraints that you set on its child views."
“使用自动布局设置滚动视图的 contentSize 时,内容大小会自动根据您在其子视图上设置的约束得出。”
The problem is still there when I update the ViewContoller
code to accommodate this advice.
当我更新ViewContoller
代码以适应此建议时,问题仍然存在。
回答by DenVog
I had a similar issue. I was able to add constraints for items on a Table View Cell - Content View (e.g. UILabel, UIImageView), once I switched the Table View Cell Style to Custom.
我有一个类似的问题。一旦我将表格视图单元格样式切换为自定义,我就能够为表格视图单元格 - 内容视图(例如 UILabel、UIImageView)上的项目添加约束。
If I added images or UILabels on top of a default Table View Cell type (e.g. Subtitle), I could position them on the Content View, but couldn't set constraints on them.
如果我在默认表格视图单元格类型(例如副标题)之上添加图像或 UILabels,我可以将它们放置在内容视图上,但不能对它们设置约束。
Changing to Custom Table View Cell Style was the solution for me.
更改为自定义表格视图单元格样式是我的解决方案。
回答by Christian Seiler
To set the constraints you need to select the items and then set the constraints with either the constraints menu or with ctrl+drag.
要设置约束,您需要选择项目,然后使用约束菜单或按住 ctrl+拖动来设置约束。
However, there is no way to set constraints for a tableViewController
as it is a already completely set up.
但是,没有办法为 a 设置约束,tableViewController
因为它已经完全设置好了。