向UIView添加两个视图

时间:2012-12-26 15:37:40

标签: objective-c uitableview uiview

我有一个故事板文件,我添加了一个UITableView和一个UIView。 UIView是我尝试制作一个半透明的自定义标题,因此通过它可以看到tableview(我不确定这是否可能,因为我是新手,这是我的第一个iPhone应用程序)。

在处理了我的ViewController类的所有连接后,当我运行代码时,我给了我这个错误:

Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.          
Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
"<NSAutoresizingMaskLayoutConstraint:0x8988060 h=--& v=--& V:[UIView:0x7574100(460)]>",
"<NSLayoutConstraint:0x7574780 V:|-(0)-[UIView:0x75742b0]   (Names: '|':UIView:0x7574100      )>",
"<NSLayoutConstraint:0x7574700 V:[UIView:0x75742b0]-(494)-|   (Names: '|':UIView:0x7574100)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7574700 V:[UIView:0x75742b0]-(494)-|   (Names: '|':UIView:0x7574100     )>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in   <UIKit/UIView.h> may also be helpful. 

任何关于为什么会这样做的想法都会有所帮助。感谢。

1 个答案:

答案 0 :(得分:2)

您已在界面构建器中配置了一个不可能的状态,正如消息所示,您无法同时满足您的布局约束。当你是新手时,我建议禁用自动布局约束(转到文档选项卡 - 最左边的选项卡 - 在界面构建器中并取消选中自动布局)这将使你摆脱这个问题

是的,你可以互相拥有两个视图,你只需要使用alpha值来配置半透明度