I want to change some constraints aromatically in different cases.
Declaration of my Constraints coming from the storyboard:
    @IBOutlet weak var topConstraintPostImageView: NSLayoutConstraint!
    @IBOutlet weak var heightConstraint: NSLayoutConstraint!
This is my code, where I want to change the constraints:
func updateCellView(post: PostModel) {
    // Wenn Bild mit Text gepostet wird
    if post.imageURL != nil && post.postText != nil {
        topConstraintPostImageView.constant = 10
        // Wenn Text ohne bild gepostet wird
    } else if post.imageURL == nil && post.postText != nil  {
        heightConstraint.constant = 1
        // Wenn Bild ohne Text gepostet wird
    } else if post.imageURL != nil && post.postText == nil {
        topConstraintPostImageView.constant = 0
    }
}
But the constraints still doesn't change.
Here my cellForRowAt func:
    extension DiscoveryViewController: UITableViewDataSource {
    // wie viele Zellen
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return postArray.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "DiscoveryCollectionViewCell", for: indexPath) as! DiscoveryCollectionViewCell
        cell.updateCellView(post: postArray[indexPath.row].post!)
        cell.layoutIfNeeded()
        cell.user = postArray[indexPath.row]
        cell.post = postArray[indexPath.row]
        cell.delegate = self
        return cell
    }
}
Thanks in advance for your help!

 
     
    