- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我收到以下错误,即使我在添加按钮和应用约束之前设置了表格 View 页脚。在 -viewDidLoad
和 -viewDidAppear
中设置和页脚 View 后,我尝试调用以下方法。我似乎无法隔离问题。
The view hierarchy is not prepared for the constraint: When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
2015-08-12 15:43:05.086 myApp[2293:299005] View hierarchy unprepared for constraint. Constraint: Container hierarchy: > | > View not found in container hierarchy: > That view's superview: ; layer = ; contentOffset: {0, 0}; contentSize: {800, 75}>
这是我用来添加按钮和应用约束的代码:
- (void)addButtonContraints{
//Create button
_nextQuestionButton = [UIButton buttonWithType:UIButtonTypeSystem];
[_nextQuestionButton addTarget:self action:@selector(nextQuestion) forControlEvents:UIControlEventTouchUpInside];
//_nextQuestionButton.frame = CGRectMake(0, 0, 200,40);
[_nextQuestionButton setTitle:@"Next Question" forState:UIControlStateNormal];
[_nextQuestionButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
_nextQuestionButton.backgroundColor = [UIColor whiteColor];
_nextQuestionButton.titleLabel.attributedText = [[NSAttributedString alloc] initWithString:@"Next Question"
attributes:@{NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont fontWithName:@"HelveticaNeue-Bold" size:18.0f]}];
//Add shadow to button
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:_nextQuestionButton.bounds];
_nextQuestionButton.layer.masksToBounds = NO;
_nextQuestionButton.layer.shadowColor = [UIColor blackColor].CGColor;
_nextQuestionButton.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
_nextQuestionButton.layer.shadowOpacity = 0.25f;
_nextQuestionButton.layer.shadowPath = shadowPath.CGPath;
[_nextQuestionButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.quizTableView.tableFooterView addSubview:_nextQuestionButton];
//Add contraints to button
NSDictionary *dict = NSDictionaryOfVariableBindings(_nextQuestionButton);
//width
[_nextQuestionButton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[_nextQuestionButton(200)]"
options:0x00
metrics:nil
views:dict]];
//height
[_nextQuestionButton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_nextQuestionButton(40)]"
options:0x00
metrics:nil
views:dict]];
//right
[_nextQuestionButton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[_nextQuestionButton]-40-|"
options:0x00
metrics:nil
views:dict]];
//top
[_nextQuestionButton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-20-[_nextQuestionButton]"
options:0x00
metrics:nil
views:dict]];
_nextQuestionButton.hidden = YES;
}
最佳答案
您应该将最后两个约束添加到您的 self.quizTableView.tableFooterView,而不是 _nextQuestionButton。
关于ios - View 层次结构没有为约束准备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31974174/
我正在尝试将多个水平链接的 Button 和 TextView 垂直链接为 View 集,但仍保持平面 View 层次结构。这是我的初始布局和代码:
到目前为止,我已经在Google BigQuery上训练了几种模型,目前我需要查看模型的外观(即架构,损失函数等)。 有没有办法获取这些信息? 最佳答案 仔细阅读文档后,我可以说该功能尚不存在。我什至
本文实例讲述了PHP实现二叉树深度优先遍历(前序、中序、后序)和广度优先遍历(层次)。分享给大家供大家参考,具体如下: 前言: 深度优先遍历:对每一个可能的分支路径深入到不能再深入为止,而且每个
我是一名优秀的程序员,十分优秀!