From 8f4e7f82c3a9eb2d9455d169edbd975b29037575 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 22 Apr 2020 15:10:41 -0400 Subject: [PATCH] update cells --- .../ProgrammaticTableViewController.swift | 5 +++++ .../ThreeLayerTableViewController.swift | 16 +++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift index b27845b3..20ec3c43 100644 --- a/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift @@ -67,6 +67,11 @@ open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UI tableView.sectionFooterHeight = CGFloat.leastNormalMagnitude } + open func refreshTable() { + tableView.beginUpdates() + tableView.endUpdates() + } + /// For subclassing, returns the number of sections for table. This function calls numberOfSectionsForTableview aftre ensuring the table is setup properly. open func getNumberOfSections() -> Int { return 1 diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index d884af42..a8230381 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -15,7 +15,6 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { private var bottomView: UIView? private var headerView: UIView? private var footerView: UIView? - var useMargins: Bool = true public var bottomViewOutsideOfScrollArea: Bool = false public var topViewOutsideOfScrollArea: Bool = false private var topViewBottomConstraint: NSLayoutConstraint? @@ -113,6 +112,9 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { bottomViewTopConstraint?.constant = newSpace showFooter(width) } + DispatchQueue.main.async { + self.refreshTable() + } } super.updateViewConstraints() } @@ -162,10 +164,10 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { func showHeader(_ sizingWidth: CGFloat?) { headerView?.removeFromSuperview() tableView?.tableHeaderView = nil - guard let topView = topView, - let headerView = headerView else { return } + guard let headerView = headerView else { return } - if topViewOutsideOfScrollArea { + if topViewOutsideOfScrollArea, + let topView = topView { // put top view outside of scrolling area. topConstraint?.isActive = false view.addSubview(topView) @@ -189,14 +191,14 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { /// Takes the current footerView and adds it to the tableFooterView func showFooter(_ sizingWidth: CGFloat?) { footerView?.removeFromSuperview() - guard let bottomView = bottomView, - let footerView = footerView, + guard let footerView = footerView, let tableView = tableView else { self.tableView?.tableFooterView = nil return } - if bottomViewOutsideOfScrollArea { + if bottomViewOutsideOfScrollArea, + let bottomView = bottomView { // put bottom view outside of scrolling area. bottomConstraint?.isActive = false view.addSubview(bottomView)