テキストビューの内容が静的である場合。 UITextViewでSrollingEnabledをfalseに設定します。
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 200
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
textviewの内容が動的である場合。
スタティックと同じことを行い、UITextViewのデリゲートをselfに設定します。その後、UITextviewデリゲートで。
func textViewDidChange(_ textView: UITextView) {
tableView.beginUpdates()
tableView.endUpdates()
}
これは間違いなく機能します。
素晴らしいです。私が入力している間は自動的に更新されないという問題のみですが、UITextViewのコンテンツは静的でなく変更されません。 –
確認できる回答を編集しました。 –
あなたがそれを持っていないか教えてください。 –