diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index 5cd7086b..8e01cf6c 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -177,8 +177,8 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { topConstraint?.isActive = false view.addSubview(topView) topView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true - topView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true - view.safeAreaLayoutGuide.rightAnchor.constraint(equalTo: topView.rightAnchor).isActive = true + topView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true + view.rightAnchor.constraint(equalTo: topView.rightAnchor).isActive = true tableView.topAnchor.constraint(equalTo: topView.bottomAnchor).isActive = true } else { topConstraint?.isActive = true @@ -208,21 +208,19 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { bottomConstraint?.isActive = false view.addSubview(bottomView) bottomView.topAnchor.constraint(equalTo: tableView.bottomAnchor).isActive = true - bottomView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true - view.safeAreaLayoutGuide.rightAnchor.constraint(equalTo: bottomView.rightAnchor).isActive = true + bottomView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true + view.rightAnchor.constraint(equalTo: bottomView.rightAnchor).isActive = true view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: bottomView.bottomAnchor).isActive = true } else { bottomConstraint?.isActive = true } - var y: CGFloat? - if let tableFooterView = tableView.tableFooterView { - // if footer already exists, use the same y location to avoid strange moving animation - y = tableFooterView.frame.minY - } + + // if footer already exists, use the same y location to avoid strange moving animation + let y = tableView.tableFooterView?.frame.minY ?? 0.0 // This extra view is needed because of the wonkiness of apple's table footer. Things breaks if using autolayout. MVMCoreUIUtility.sizeView(toFit: footerView) - let tableFooterView = UIView(frame: CGRect(x: 0, y: y ?? 0, width: MVMCoreUIUtility.getWidth(), height: footerView.frame.height)) + let tableFooterView = UIView(frame: CGRect(x: 0, y: y, width: MVMCoreUIUtility.getWidth(), height: footerView.frame.height)) tableFooterView.addSubview(footerView) NSLayoutConstraint.constraintPinSubview(toSuperview: footerView) tableView.tableFooterView = tableFooterView @@ -232,7 +230,7 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { /// Subclass for a top view. open func viewForTop() -> UIView { // Small height is needed to stop apple from adding padding for grouped tables when no header. - return MVMCoreUICommonViewsUtility.getView(with: 1) + return MVMCoreUICommonViewsUtility.getView(with: 0.5) } /// Subclass for a bottom view.