URLNavigator icon indicating copy to clipboard operation
URLNavigator copied to clipboard

How to pop an viewController?

Open qiushuitian opened this issue 6 years ago • 3 comments

hello, I implement the push like this in my viewModel:

let context = ["merch":merch]
DJNavigator.share.push("myApp://roomList/",context:context)

And In the roomListViewController I want pop to current viewController when I click the back button. But I have to write the code in the viewController (not in the viewModel) use origin pop:

self.navigationController?.popViewController(animated: true)

Can I do it using the URLNavigator so that I can write all view navigtion logic in viewModel ?

qiushuitian avatar Apr 05 '18 03:04 qiushuitian

URLNavigator doesn't support popping view controllers. If it is needed, you can still make an extension.

devxoul avatar Apr 15 '18 16:04 devxoul

@devxoul How?

thepinyo avatar Apr 27 '18 03:04 thepinyo

@thepinyo Like this:

extension Navigator {
  func pop(animated: Bool = true) {
    UIViewController.topMost?.navigationController?.popViewController(animated: animated)
  }
}

devxoul avatar Apr 27 '18 08:04 devxoul