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

Fix: delegate's methods of the subclass of NavigationStackController are not called #259

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

takehilo
Copy link

As shown below, an instance of NavigationDelegate is set to delegate property in a subclass of NavigationStackController.

ExampleNavigationStackController: NavigationStackController {
  private let navigationDelegate: NavigationDelegate

  public override func viewDidLoad() {
    super.viewDidLoad()
    delegate = navigationDelegate
  }
}

class NavigationDelegate: NSObject, UINavigationControllerDelegate {
  func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
    // ... not called
  }

  func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
    // ... called
  }
}

However, navigationController(_:willShow:animated:) is not called, while navigationController(_:didShow:animated:) is called.

In the viewDidLoad method of NavigationStackController, an instance of PathDelegate is assigned to delegate property. At this point, an implementation check using responds(to:) is performed. However, since NavigationDelegate has not yet been set, navigationController(_:willShow:animated:) is determined to be unimplemented.

To address this, I added the missing methods to responds(to:).

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

Successfully merging this pull request may close these issues.

1 participant