Tag: nsautolayout

UIViewController在Xcode 7中挂起

不知道是否标题是正确的,我打电话给newViewControllerbutton点击,但它没有渲染。 因为它在Xcode 6.4中工作正常,但是在Xcode 7中它挂起了UI,并且在pushViewController之后没有显示新的视图控制器。 这是在控制台上打印的错误日志 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 […]

具有dynamic大小的单元格的复杂AutoLayout

我有一个包含10个子视图的容器(其中两个是简单的界限,其他是标签)。 该计划看起来像这样。 dynamic标签可能包含巨大的文本,所以单元格应该符合适当的大小以适应内容。 问题是如何手动设置所有的约束…我已经尝试了十几次自己做,但似乎我不擅长这一点。 表视图支持行高的自动尺寸,并使用自定义的估计高度。 在故事板中,它看起来是这样的。 其中蓝色视图是视图C的子视图 。 后面的灰色视图是视图B. 粗体标签是静态的,其他标签是dynamic的。 演示项目 。 如何设置约束? 提前非常感谢!

可以子视图自动调整自己的超级视图自动布局?

如果您有一个没有约束的视图,并且该视图具有大小相等的左,右,顶部和底部约束的子视图,则如果子视图的大小增加,则超级视图的大小可以自动增加以适应这些约束? 谢谢。

Autolayout以编程方式不起作用

我想以编程方式将UIImageView添加到视图,并添加约束来垂直和水平居中。 故事板是有效的,但不是以编程方式。 class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() var transitionImageView = UIImageView() transitionImageView.frame.size = CGSize(width: 60, height: 68) transitionImageView.contentMode = UIViewContentMode.ScaleToFill var transitionImage = UIImage(named: "SoProxyLogo60pt") transitionImageView.image = transitionImage self.view.addSubview(transitionImageView) // Position let transitionImageViewConstraintCenterX = NSLayoutConstraint(item: transitionImageView, attribute: .CenterX, relatedBy: .Equal, toItem: self.view, attribute: .CenterX, multiplier: 1, constant: 0) transitionImageViewConstraintCenterX.identifier = "Transition […]

AutoLayout,无法同时满足约束

刚开始学习iOS AutoLayout时,Interface Builder的构build非常简单,但是当我尝试在代码上存档相同的东西的时候 [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(==2)-[_nextKeyboardButton]-(==2)-[_numPadButton]-(==2)-[_spaceButton]-(==2)-[_returnButton]-(==2)-|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_nextKeyboardButton,_numPadButton,_spaceButton,_returnButton)]]; 它引发了一个例外, 无法同时满足约束。 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 […]