Compare commits

..

4 Commits

Author SHA1 Message Date
jonkykong 44d1de7d48 Upped podspec 2019-07-17 09:44:50 -07:00
jonkykong 287434b008 Refactor 2019-07-17 09:44:33 -07:00
jonkykong c0ec53608f Fix for unresponsive presentation 2019-07-17 09:36:55 -07:00
jonkykong 54a9f3887d Fix for programmatic instantiation not calling setup() 2019-07-17 02:49:10 -07:00
2 changed files with 25 additions and 21 deletions
@@ -76,7 +76,7 @@ open class UISideMenuNavigationController: UINavigationController {
else: { _ in Menu.elseCondition(.leftSide) } )
private weak var _sideMenuManager: SideMenuManager?
private weak var foundDelegate: UISideMenuNavigationControllerDelegate?
private weak var foundViewController: UIViewController?
private weak var interactionController: SideMenuInteractionController?
private var interactive: Bool = false
private var originalBackgroundColor: UIColor?
@@ -112,16 +112,13 @@ open class UISideMenuNavigationController: UINavigationController {
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
public convenience init(_ block: (UISideMenuNavigationController) -> Void) {
self.init()
block(self)
setup()
}
public init(rootViewController: UIViewController, settings: SideMenuSettings = SideMenuSettings()) {
super.init(rootViewController: rootViewController)
self.settings = settings
setup()
}
required public init?(coder aDecoder: NSCoder) {
@@ -144,7 +141,7 @@ open class UISideMenuNavigationController: UINavigationController {
// Dismiss keyboard to prevent weird keyboard animations from occurring during transition
presentingViewController?.view.endEditing(true)
foundDelegate = nil
foundViewController = nil
activeDelegate?.sideMenuWillAppear?(menu: self, animated: animated)
}
@@ -193,7 +190,7 @@ open class UISideMenuNavigationController: UINavigationController {
// the view hierarchy leaving the screen black/empty. This is because the transition moves views within a container
// view, but dismissing without animation removes the container view before the original hierarchy is restored.
// This check corrects that.
if presentedViewController == nil && view.window == nil {
if let foundViewController = self.visibleViewController(from: presentingViewController), foundViewController.view.window == nil {
transitionController?.transition(presenting: false, animated: false)
}
@@ -211,6 +208,7 @@ open class UISideMenuNavigationController: UINavigationController {
view.isHidden = true
} else {
transitionController = nil
interactive = false
}
}
@@ -240,7 +238,7 @@ open class UISideMenuNavigationController: UINavigationController {
override open func pushViewController(_ viewController: UIViewController, animated: Bool) {
let push = shouldPushViewController(viewController: viewController, animated: animated) { [weak self] _ in
self?.foundDelegate = nil
self?.foundViewController = nil
}
if push {
@@ -392,7 +390,7 @@ extension UISideMenuNavigationController: UIViewControllerTransitioningDelegate
return interactionController(using: animator)
}
open func interactionController(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
private func interactionController(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
guard interactive else { return nil }
let interactionController = SideMenuInteractionController(cancelWhenBackgrounded: dismissWhenBackgrounded, completionCurve: completionCurve)
self.interactionController = interactionController
@@ -553,22 +551,28 @@ private extension UISideMenuNavigationController {
weak var activeDelegate: UISideMenuNavigationControllerDelegate? {
guard !view.isHidden else { return nil }
return sideMenuDelegate ?? foundDelegate ?? findDelegate(forViewController: presentingViewController)
if let sideMenuDelegate = sideMenuDelegate {
return sideMenuDelegate
}
return visibleViewController(from: presentingViewController) as? UISideMenuNavigationControllerDelegate
}
func findDelegate(forViewController: UIViewController?) -> UISideMenuNavigationControllerDelegate? {
if let navigationController = forViewController as? UINavigationController {
return findDelegate(forViewController: navigationController.topViewController)
func visibleViewController(from: UIViewController?) -> UIViewController? {
if let foundDelegate = foundViewController {
return foundDelegate
}
if let tabBarController = forViewController as? UITabBarController {
return findDelegate(forViewController: tabBarController.selectedViewController)
if let navigationController = from as? UINavigationController {
return visibleViewController(from: navigationController.topViewController)
}
if let splitViewController = forViewController as? UISplitViewController {
return findDelegate(forViewController: splitViewController.viewControllers.last)
if let tabBarController = from as? UITabBarController {
return visibleViewController(from: tabBarController.selectedViewController)
}
if let splitViewController = from as? UISplitViewController {
return visibleViewController(from: splitViewController.viewControllers.last)
}
foundDelegate = forViewController as? UISideMenuNavigationControllerDelegate
return foundDelegate
foundViewController = from
return from
}
func setup() {
+1 -1
View File
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = "SideMenu"
s.version = "6.0.2"
s.version = "6.0.3"
s.summary = "Simple side menu control for iOS in Swift inspired by Facebook. Right and Left sides. No coding required."
# This description is used to generate tags and improve search results.