iOS 기본 알림 앱과 유사한 앱을 제작하려고합니다. 머리글과 바닥 글이있는 항목 목록이있는 곳입니다. 각 셀에는 사용자 입력시 동적으로 셀 높이를 변경하는 UITextView
이 있습니다. 바닥 글보기에는 바닥 글보기를 유지하기 위해 바닥 글이되고 싶다는 점을 제외하고는 동일한 셀보기가 포함되어 있습니다. 셀이 동적 높이로 설정되어 있습니다.UITableView reloadSections가 viewForFooterInSection을 트리거하지 않습니까?
checklistTable.rowHeight = UITableViewAutomaticDimension
checklistTable.estimatedRowHeight = 60
checklistTable.sectionFooterHeight = UITableViewAutomaticDimension
checklistTable.estimatedSectionFooterHeight = 60
여기는 입력하는 동안 셀 높이를 업데이트하는 로직입니다. 일반 셀에서는 완벽하게 작동하지만 바닥 글보기에서는 작동하지 않습니다. viewForFooterInSection에 중단 점을 설정했으나 초기로드 후에는 호출되지 않았습니다.
func textViewDidChange(_ textView: UITextView) {
let startHeight = textView.frame.size.height
let calcHeight = textView.sizeThatFits(textView.frame.size).height
if startHeight != calcHeight {
UIView.setAnimationsEnabled(false)
tableView?.beginUpdates()
if cellType == .footer {
tableView?.reloadSections(IndexSet(integer: 0), with: .automatic)
}
tableView?.endUpdates()
UIView.setAnimationsEnabled(true)
}
}
누구나 올바른 방향으로 나를 가리킬 수 있습니까? tableView?.beginUpdates()
를 호출 UIView
&에 감사
라고나요 :
단순히
reloadSections
를 호출하는 것은 같은 일을해야합니까? –API 문서는이 메서드가 머리글과 바닥 글이 아니라 셀을 업데이트한다고 말합니다. – picciano
@nirav 예, viewForFooterInSection은 호출을 초기화합니다. 언젠가 스크롤하는 동안 –