データでTableViewCellが設定されています。たとえば、ラベルを1つだけ表示したい場合、ユーザーがセルをクリックすると、セルがサイズ変更され、すべてのデータがユーザーに表示されます。私は部分のサイズを変更していますが、セルが小さいときは自動的に制約が変わります。誰かが私を助けることができますか?下の写真をコードしてください。クリック後にUITableViewCellのサイズが変更され、制約が変更されています
ありがとうございます!
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (i != indexPath.row) {
i = indexPath.row
}
else {
i = -1
}
tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if (indexPath.row == i) {
return 250
}
else {
return 50
}
}
ありがとう、私は私のセルの中にビューを持っていて、余白に制約がありました。私はちょうどこのViewの制約を一定に設定しています。 – deniskakacka