title: I cannot figure out what causes layout constraint warnings in my message bubble cell
body: <p>I've been trying to solve this problem for a few days now and I haven't been able to understand what is wrong with my constraints, and warnings keep popping up in the console.
  Here are my UI elements:</p>
  
  <pre><code>let messageText : UILabel = {
      let label = UILabel()
      label.translatesAutoresizingMaskIntoConstraints = false
      label.numberOfLines = 0
      label.backgroundColor = .clear
      label.clipsToBounds = false
      label.font = UIFont.systemFont(ofSize: 17)
      return label
  }()
  
  private let messageCard : UIView = {
      let card = UIView()
      card.translatesAutoresizingMaskIntoConstraints = false
      card.layer.cornerRadius = 16
      card.layer.masksToBounds = true
      card.clipsToBounds = false
      return card
  }()
  
  private let avatar : CachedImageView = {
      var imageView = CachedImageView()
      imageView.translatesAutoresizingMaskIntoConstraints = false
      imageView.heightAnchor.constraint(equalToConstant: 15).isActive = true
      imageView.heightAnchor.constraint(equalToConstant: 15).isActive = true
      imageView.isAvatar = true
      return imageView
  }()
  
  private let stackView : UIStackView = {
      let stView = UIStackView()
      stView.translatesAutoresizingMaskIntoConstraints = false
      stView.backgroundColor = .clear
      stView.axis = .vertical
      return stView
  }()
  </code></pre>
  
  <p>Here is my initialiser for the cell:</p>
  
  <pre><code>override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
      super.init(style: style, reuseIdentifier: reuseIdentifier)
  
      self.clipsToBounds = false
  
      stackView.addArrangedSubview(messageText)
      stackView.addArrangedSubview(avatar)
      addSubview(messageCard)
      addSubview(stackView)
  
      let constraints = [
          stackView.topAnchor.constraint(equalTo: topAnchor, constant: bubbleMargin + bubblePadding),
          stackView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -(bubbleMargin + bubblePadding)),
          stackView.widthAnchor.constraint(lessThanOrEqualToConstant: 300),
          stackView.widthAnchor.constraint(greaterThanOrEqualToConstant: 30),
          //stackView.heightAnchor.constraint(greaterThanOrEqualToConstant: 10), // ну хз
  
          messageCard.topAnchor.constraint(equalTo: stackView.topAnchor, constant: -bubblePadding),
          messageCard.bottomAnchor.constraint(equalTo: stackView.bottomAnchor, constant: bubblePadding),
          messageCard.leadingAnchor.constraint(equalTo: stackView.leadingAnchor, constant: -bubblePadding),
          messageCard.trailingAnchor.constraint(equalTo: stackView.trailingAnchor, constant: bubblePadding),
  
          /*messageText.leadingAnchor.constraint(equalTo: stackView.leadingAnchor, constant: 20),
          messageText.trailingAnchor.constraint(equalTo: stackView.trailingAnchor, constant: -20),*/
  
          /*avatar.heightAnchor.constraint(equalToConstant: 15),
          avatar.widthAnchor.constraint(equalToConstant: 15),
          avatar.centerXAnchor.constraint(equalTo: stackView.centerXAnchor),
          avatar.centerYAnchor.constraint(equalTo: stackView.centerYAnchor),*/
      ]
  
      leftConstr = stackView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: bubbleMargin + bubblePadding)
      rightConstr = stackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -(bubbleMargin + bubblePadding))
  
      leftConstr.isActive = true
  
      for c in constraints {
          c.isActive = true
      }
  }
  </code></pre>
  
  <p>Here is the method that fills the message bubble:</p>
  
  <pre><code>func setMessage() {
      messageText.text = messageWrapper.message.text
      messageText.textColor = .white
      messageCard.backgroundColor = messageWrapper.message.out == 1 ? .darkGray : .lightGray
      leftConstr.isActive = messageWrapper.message.out == 0
      rightConstr.isActive = messageWrapper.message.out == 1
      avatar.isHidden = messageWrapper.message.out == 1
      if messageWrapper.message.out == 0 {
          if let photo = messageWrapper.group?.photo50 {
              avatar.setSource(url: photo)
          }
          if let photo = messageWrapper.profile?.photo100 {
              avatar.setSource(url: photo)
          }
      }
  }
  </code></pre>
  
  <p>I've also noticed that the warnings really only appear when I start scrolling, but the warning suggests that there is something wrong with a constraints that the setMessage() method doesn't ever touch.</p>
  
  <p><a href="https://i.stack.imgur.com/USD7C.png" rel="nofollow noreferrer">screenshot of the warning, since stack overflow really wasn't having it as a code snippet</a></p>