Я вычисляю конечные ограничения для стекового представления, которое находится внутри табличного представления.Кажется, что расчет не дает точного значения.Пожалуйста, обратитесь к скриншоту ниже.Мой расчет / логика неверны?Как это исправить, чтобы я мог получить точное значение?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "tableCellID", for: indexPath) as? TableViewCell else {
fatalError("Can't find cell")
}
let profile = array[indexPath.row]
if profile.isDisabled1 || profile.isDisabled2 || profile.isDisabled3 {
let totalHiddenViews: Int = (profile.isDisabled1 ? 1 : 0) + (profile.isDisabled2 ? 1 : 0) + (profile.isDisabled3 ? 1 : 0)
let singleViewWidth = (UIScreen.main.bounds.size.width - 32)/3 // 32 is sum of leading and trailing constraints
cell.stackViewTrailing.constant = CGFloat(totalHiddenViews) * (singleViewWidth + 8)
} else {
cell.stackViewTrailing.constant = 8
}
cell.view1.isHidden = profile.isDisabled1
cell.view2.isHidden = profile.isDisabled2
cell.view3.isHidden = profile.isDisabled3
return cell
}
![Scraanshot](https://i.stack.imgur.com/YERqe.png)