badoo / badoo/Chatto

Constraints problem when adding DemoChatViewController as a child view controller

Open
#494 4 comments 0 reactions 1 assignee Claimed by @wiruzx View on GitHub
bug help wanted
Dominant language
Swift
Stars
4.6k
Forks
588
PR merge metrics
No merged PRs in 30d

Description

I am trying to add DemoChatViewController(subclass of BaseChatViewController) into a view as a child view controller:

addChildViewController(child)
child.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(child.view)
child.didMove(toParentViewController: self)

view.addConstraints([
NSLayoutConstraint(item: child.view, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: 0),
NSLayoutConstraint(item: child.view, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1, constant: 0),
NSLayoutConstraint(item: child.view, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1, constant: 0),
NSLayoutConstraint(item: child.view, attribute: .trailing, relatedBy: .equal, toItem: view, attribute: .trailing, multiplier: 1, constant: 0)
])

But I got runtime error: Unable to simultaneously satisfy constraints.
"<_UILayoutSupportConstraint:0x600000285960 _UILayoutSpacer:0x6000005cce40'UIVC-topLayoutGuide'.height == 0 (active)>",
"<_UILayoutSupportConstraint:0x600000284f60 V:|-(0)-[_UILayoutSpacer:0x6000005cce40'UIVC-topLayoutGuide'] (active, names: '|':Chatto.BaseChatViewControllerView:0x7fa67342a940 )>",
"",
"",
"=0)-[UIView:0x7fa66df6f110] (active)>",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
)

Will attempt to recover by breaking constraint

Any suggestion? Thanks in advance.
Cheers

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.