I'm a new in the programming and I know that there are a lot of staff about auto-layout or manipulation with constraints in the internet/stackoverflow and I searched everywhere however was unable to find answer on my question, so please advise if you can. For example here is UI example
So I have a tableView which is top constaints to top of ViewController and textView which is top constraints to bottom of tableView. So the question is, how can I dynamically change constraints based on the size of array in TableView. If TableView is empty, so then assign textView to ViewController, if array of tableView > 0, then assign to bottom of TableView. I tried something like this
@IBOutlet weak var textViewTopConstraints: NSLayoutConstraint! {
didSet {
if array.isEmpty {
textViewTopConstraints.isActive = false
textView.topAnchor.constraint(equalTo: ViewController.top, constant: 8).isActive = true
} else if imageURL.count > 0 {
textViewTopConstraints.isActive = false
textView.topAnchor.constraint(equalTo: tableView.bottomAnchor, constant: 8).isActive = true
}
}
}
However it's only working when app is loaded and then didn't call if array is changed. So basically, I can't understand how to call function or something that will track and change my constraints based on the size of my array. If this is a duplicate, could you please guide me to the right link where I can check this information.