2017-09-08 6 views
1

reloadDataを使用してセクションフッターをリフレッシュしたいのですが、最後のセクションを除いてすべてのセクションが更新されています - footerが表示されていてもviewForFooterInSectionは呼び出されません。ビューのスクロールは、最後のセクションのviewForFooterInSectionを呼び出す唯一の方法です。この行動の理由は何でしょうか?私はAutolayoutを使用しています。viewForFooterInSectionがreloadDataの最後のセクションで呼び出されていない

EDIT:heightForFooterInSectionは、異なるフッターの高さをサポートするように実装されていますが、AutomaticDimensionを返すだけで、ロジックは別の場所に移動する必要がありますか?これを使用する

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { 
     switch(tableView) { 
     case self.firstTableView: 
      let item = self.firstItems[section] 
      let shouldShowFirstButton = myModel.hasActions(item) 
      let shouldShowSecondButton = myModel.hasOtherActions(item) 
      if shouldShowFirstButton && shouldShowSecondButton { 
       return FirstFooterView.heightForTwoButtons() 
      } else if shouldShowFirstButton ||shouldShowSecondButton{ 
       return FirstFooterView.heightForOneButton() 
      } else { 
       return OtherFooterView.height() 
      } 
     case self.secondTableView: 
      return 0.0 
     case self.thirdTableView: 
      if self.state1 { 
       return 70.0 
      } else if selectedItem == nil { 
       return 0.0 
      }else{ 
       return 0.0 
      } 
     default: 
      DDLogInfo("height 0 for section \(section)") 
      return 1.0 
     } 
+3

にスクロールしたい場合は、ここに関連するコードを投稿してくださいことはできますか? –

答えて

0
UiView.setAnimationsEnabled(False) 
self.TableView.reloadSections(NSIndexSet(index: yoursection), 
withRowAnimation: UITableViewRowAnimation.None) 
self.TableView.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 5), 
atScrollPosition: UITableViewScrollPosition.Bottom, animated: false) 
UIView.setAnimationsEnabled(true) 

あなたがリロードしたい特定のセクションをリロードすることができます。それは

編集に役立ちます願って:あなたは、特定の位置

self.TableView.scrollRectToVisible(<#T##rect: CGRect##CGRect#>, animated: <#T##Bool#>) 
+0

ありがとう、これは動作するようです! .bottomのようなスクロール位置の代わりにリロードの前に正確な位置にスクロールする方法があるかどうか疑問に思っていますか? – Dan

+0

列挙型を設定する必要があります。しかし、それ以外の方法は、このself.TableView.scrollRectToVisible:CGRect(x:0、y:0、幅:1、高さ:1)アニメーション:false – cole

+0

のようなものになります私の答えに満足している場合。同意してください – cole

関連する問題