2017-03-02 1 views
1

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 &에 감사

+0

라고나요 :
단순히 reloadSections를 호출하는 것은 같은 일을해야합니까? –

+0

API 문서는이 메서드가 머리글과 바닥 글이 아니라 셀을 업데이트한다고 말합니다. – picciano

+0

@nirav 예, viewForFooterInSection은 호출을 초기화합니다. 언젠가 스크롤하는 동안 –

답변

2

사용 & 해제 애니메이션이 동시에 모호한 보인다. viewForFooterInSection 이제까지 처음

if startHeight != calcHeight { 

     if cellType == .footer { 
      tableView?.reloadSections(IndexSet(integer: 0), with: .automatic) 
     } 
    } 
+0

고마워요 @ystack. 나는 그것을 시도하고 아무런 차이가 없습니다 : ( –

+0

woah!) 간단한'table.reloadData()'를 수행 해본 적이 있습니까? – ystack

+0

reloadData는 아마도 바닥 글을 다시 그릴 것입니다.하지만 전체 테이블을 다시로드하지 않고도 섹션 바닥 글을 업데이트하는 우아한 방법을 찾고 있습니다. 다시로드하면 키보드가 닫히고 사용자가 입력하는 동안 원하지 않습니다. –

관련 문제