From a74923b7b29a63a3fd0da7aa27ca8c09e6a72a2f Mon Sep 17 00:00:00 2001 From: David Ask Date: Thu, 23 Aug 2018 21:32:20 +0200 Subject: [PATCH] Add support for forwarding container view controller methods --- Framework/StateViewController.h | 2 -- Sources/StateViewController.swift | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Framework/StateViewController.h b/Framework/StateViewController.h index a26f28b..8dc96a9 100644 --- a/Framework/StateViewController.h +++ b/Framework/StateViewController.h @@ -5,5 +5,3 @@ FOUNDATION_EXPORT double StateViewControllerVersionNumber; //! Project version string for StateViewController. FOUNDATION_EXPORT const unsigned char StateViewControllerVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import diff --git a/Sources/StateViewController.swift b/Sources/StateViewController.swift index a58acae..85a6dd6 100644 --- a/Sources/StateViewController.swift +++ b/Sources/StateViewController.swift @@ -249,6 +249,26 @@ open class StateViewController: UIViewController { endStateTransitionIfNeeded(animated: animated) } + // MARK: - Container view controller forwarding + + open override var childViewControllerForStatusBarStyle: UIViewController? { + return childViewControllers.last + } + + open override var childViewControllerForStatusBarHidden: UIViewController? { + return childViewControllers.last + } + + @available(iOS 11, *) + open override func childViewControllerForScreenEdgesDeferringSystemGestures() -> UIViewController? { + return childViewControllers.last + } + + @available(iOS 11, *) + open override func childViewControllerForHomeIndicatorAutoHidden() -> UIViewController? { + return childViewControllers.last + } + // MARK: - State transitioning /// Indicates whether the view controller currently is transitioning between states. @@ -530,6 +550,15 @@ fileprivate extension StateViewController { addContentViewController(viewController, animated: animated) } + if adding.isEmpty == false || removing.isEmpty == false { + setNeedsStatusBarAppearanceUpdate() + + if #available(iOS 11, *) { + setNeedsUpdateOfHomeIndicatorAutoHidden() + setNeedsUpdateOfScreenEdgesDeferringSystemGestures() + } + } + // Update the hierarchy of the view controllers that will represent the state being transitioned to. updateHierarchy(of: next) return true