Card View Constraints

So, how to avoid constraint conflicts when setting subviews on a card view? When I add trailing and leading constraints to the content view, it always causes conflicts.

Example:

These are the constraints:


Code Block swift
 NSLayoutConstraint.activate([   comment.widthAnchor.constraint(greaterThanOrEqualToConstant: 250),          comment.heightAnchor.constraint(greaterThanOrEqualToConstant: 300),
            userName.topAnchor.constraint(equalTo: comment.contentView.topAnchor, constant: 8),
            userName.leadingAnchor.constraint(equalTo: comment.contentView.leadingAnchor, constant: 8),
            userName.trailingAnchor.constraint(equalTo: comment.contentView.trailingAnchor, constant: -8),
            
            userScore.topAnchor.constraint(equalTo: userName.bottomAnchor, constant: 8),
            userScore.leadingAnchor.constraint(equalTo: comment.contentView.leadingAnchor, constant: 8),
            userScore.trailingAnchor.constraint(equalTo: comment.contentView.trailingAnchor, constant: -8),
            
            userComment.topAnchor.constraint(equalTo: userScore.bottomAnchor, constant: 8),
            userComment.leadingAnchor.constraint(equalTo: comment.contentView.leadingAnchor, constant: 8),
            userComment.trailingAnchor.constraint(equalTo: comment.contentView.trailingAnchor, constant: -8),
userComment.bottomAnchor.constraint(lessThanOrEqualTo: comment.contentView.bottomAnchor, constant: -8)
])


This is the error:

Code Block
(
"<NSAutoresizingMaskLayoutConstraint:0x600003710140 h=--& v=--& UIView:0x7fd3dee31a10.width == 0   (active)>",
    "<NSLayoutConstraint:0x60000372b570 H:|-(0)-[UIView:0x7fd3dee318a0]   (active, names: '|':UIView:0x7fd3dee31a10 )>",
    "<NSLayoutConstraint:0x60000372b5c0 UIView:0x7fd3dee318a0.trailing == UIView:0x7fd3dee31a10.trailing   (active)>",
    "<NSLayoutConstraint:0x60000372bd90 H:|-(8)-[UILabel:0x7fd3dee32bc0'Mark']   (active, names: '|':UIView:0x7fd3dee318a0 )>",
    "<NSLayoutConstraint:0x60000372bde0 UILabel:0x7fd3dee32bc0'Mark'.trailing == UIView:0x7fd3dee318a0.trailing - 8   (active)>"
)
Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60000372bde0 UILabel:0x7fd3dee32bc0'Mark'.trailing == UIView:0x7fd3dee318a0.trailing - 8   (active)>

Can anyone explain me why this occurs?

"<NSAutoresizingMaskLayoutConstraint:0x600003710140 h=--& v=--& UIView:0x7fd3dee31a10.width == 0   (active)>",


Looks like you want to set translatesAutoresizingMaskIntoConstraints to NO.
They are configured to no in all elements inside the card view and on the card view itself, if you try to set to no on the content view of the card view, it will crash your application.
Card View Constraints
 
 
Q