URLNavigator icon indicating copy to clipboard operation
URLNavigator copied to clipboard

Push will be invalid

Open zhaoyunyi opened this issue 6 years ago • 5 comments

if app have Multiple windows, navigator.push("") will be invaild I think that should modify UIViewController. topMost

code:

    let currentWindows = UIApplication.shared.keyWindow
    if let windowRootViewController = currentWindows?.rootViewController {
        rootViewController = windowRootViewController
    }
//    for window in currentWindows {
//      if let windowRootViewController = window.rootViewController {
//        rootViewController = windowRootViewController
//        break
//      }
//    }

zhaoyunyi avatar Jun 14 '18 03:06 zhaoyunyi

Can I have a sample project that has the bug?

devxoul avatar Jun 14 '18 08:06 devxoul

i have the same pro because my app have 2 windonws in sharedApplication?.windows i think ,you need find the keywindow

UIViewController+TopMostViewController.swft: line 15: , window.isKeyWindow

  open class var topMost: UIViewController? {
    guard let currentWindows = self.sharedApplication?.windows else { return nil }
    var rootViewController: UIViewController?
    for window in currentWindows {
        if let windowRootViewController = window.rootViewController, window.isKeyWindow {
        rootViewController = windowRootViewController
        break
      }
    }

    return self.topMost(of: rootViewController)
  }

cdoky avatar Aug 17 '18 04:08 cdoky

I had the same problem,push Sometimes return nil.

nameIsYong avatar Nov 07 '18 01:11 nameIsYong

do't set MainInterface main

cdoky avatar Nov 07 '18 02:11 cdoky

That is right,https://github.com/devxoul/URLNavigator/issues/114 Can you help me? thank you

nameIsYong avatar Nov 07 '18 02:11 nameIsYong