badoo/Chatto

Constraints problem when adding DemoChatViewController as a child view controller

Aperta

#494 aperta il 27 giu 2018

 (4 commenti) (0 reazioni) (1 assegnatario)Swift (561 fork)batch import
bughelp wanted

Metriche repository

Star
 (4166 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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 )>", "<NSAutoresizingMaskLayoutConstraint:0x604000093ce0 h=-&- v=-&- UIView:0x7fa67342a560.height == UIView:0x7fa67342a750.height (active)>", "<NSAutoresizingMaskLayoutConstraint:0x604000288e80 h=--& v=--& UIView:0x7fa673373520.height == 0 (active)>", "<NSLayoutConstraint:0x60000009ea50 V:[_UILayoutSpacer:0x6000005cce40'UIVC-topLayoutGuide']-(>=0)-[UIView:0x7fa66df6f110] (active)>", "<NSLayoutConstraint:0x600000284d30 V:[UIView:0x7fa66df6f110]-(0)-| (active, names: '|':Chatto.BaseChatViewControllerView:0x7fa67342a940 )>", "<NSLayoutConstraint:0x6040002972a0 UIView:0x7fa66b613d30.height == 44 (active)>", "<NSLayoutConstraint:0x604000483cf0 V:|-(0)-[ChattoAdditions.ExpandableTextView:0x7fa66c167000] (active, names: '|':ChattoAdditions.ChatInputBar:0x7fa67323d040 )>", "<NSLayoutConstraint:0x604000480000 V:[ChattoAdditions.ExpandableTextView:0x7fa66c167000]-(0)-[UIView:0x7fa66b613d30] (active)>", "<NSLayoutConstraint:0x604000486810 V:[UIView:0x7fa66b613d30]-(0)-| (active, names: '|':ChattoAdditions.ChatInputBar:0x7fa67323d040 )>", "<NSLayoutConstraint:0x604000093ec0 UIView:0x7fa66df6f110.top == ChattoAdditions.ChatInputBar:0x7fa67323d040.top (active)>", "<NSLayoutConstraint:0x604000287530 V:[ChattoAdditions.ChatInputBar:0x7fa67323d040]-(0)-| (active, names: '|':UIView:0x7fa66df6f110 )>", "<NSLayoutConstraint:0x604001286bd0 V:|-(0)-[Chatto.BaseChatViewControllerView:0x7fa67342a940] (active, names: '|':UIView:0x7fa67342a560 )>", "<NSLayoutConstraint:0x604001286b30 Chatto.BaseChatViewControllerView:0x7fa67342a940.bottom == UIView:0x7fa67342a560.bottom (active)>", "<NSLayoutConstraint:0x60000029c660 V:|-(0)-[UIView:0x7fa67342a750] (active, names: '|':UIView:0x7fa673373520 )>", "<NSLayoutConstraint:0x60000009f6d0 UIView:0x7fa67342a750.bottom == UIView:0x7fa673373520.bottom (active)>" )

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6040002972a0 UIView:0x7fa66b613d30.height == 44 (active)>

Any suggestion? Thanks in advance. Cheers

Guida contributor