Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SideMenuAnimationControllerDelegate assignment nil before delegate call sideMenuAnimationController(_ animationController: SideMenuAnimationController, didDismiss viewController: UIViewController) #667

Open
WineKai opened this issue Jan 6, 2021 · 0 comments

Comments

@WineKai
Copy link

WineKai commented Jan 6, 2021

I have read the guidelines for contributing and I understand
and i use the recent release version.

i found the method in class SideMenuAnimationController line 76:

    func animationEnded(_ transitionCompleted: Bool) {
        guard let presentedViewController = presentedViewController else { return }
        if presentedViewController.isHidden {
            delegate?.sideMenuAnimationController(self, didDismiss: presentedViewController) // this place, delegate has assginment nil
        } else {
            delegate?.sideMenuAnimationController(self, didPresent: presentedViewController)
        }
    }

when i tap to dismiss.delegate has assignment nil by code:

    override open func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)

        // Work-around: if the menu is dismissed without animation the transition logic is never called to restore the
        // 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 isBeingDismissed {
            transitionController?.transition(presenting: false, animated: false)
        }

        // Clear selection on UITableViewControllers when reappearing using custom transitions
        if let tableViewController = topViewController as? UITableViewController,
            let tableView = tableViewController.tableView,
            let indexPaths = tableView.indexPathsForSelectedRows,
            tableViewController.clearsSelectionOnViewWillAppear {
            indexPaths.forEach { tableView.deselectRow(at: $0, animated: false) }
        }

        activeDelegate?.sideMenuDidDisappear?(menu: self, animated: animated)

        if isBeingDismissed {
            transitionController = nil  // this place assginment nil
        } else if dismissOnPresent {
            view.isHidden = true
        }
    }

in class SideMenuNavigationController, line 258.
so the delegate cannot callback sideMenuAnimationController(self, didDismiss: presentedViewController).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant