页面不能跳转的bug
guard let currentWindows = self.sharedApplication?.windows else { return nil } var rootViewController: UIViewController? for window in currentWindows { if let windowRootViewController = window.rootViewController { rootViewController = windowRootViewController break } }
比如在其他window 也有rootViewController的时候, 并且这个时候这个windows 不是key window, 这个时候获取到rootViewControoler 就不是当前 可见的 rootviewController
Originally posted by @shenfh in https://github.com/devxoul/URLNavigator/issue_comments#issuecomment-446162236
这里的写法有问题, 正确的写法应该是: return self.topMost(of: self.sharedApplication?.delegate?.window??.rootViewController)
Does #110 fix this issue?
Does #110 fix this issue?
#110 can NOT fix this issue.
Other Example: SampleViewController :
let picker = UIImagePickerController()
self?.present(picker, animated: true, completion: nil)
Before present:
<UIWindow: 0x10701a6e0; frame = (0 0; 414 736); gestureRecognizers = <NSArray: 0x2825d4f30>; layer = <UIWindowLayer: 0x282ba4560>> viewDidLoad() > <example.LightNavigationViewController: 0x107830800> viewDidLoad() > rootController?.presentedViewController: nil viewDidLoad() > presentingViewController : nil
After present and Dismiss the UIImagePickerController:
<UIWindow: 0x10701a6e0; frame = (0 0; 414 736); gestureRecognizers = <NSArray: 0x2825d4f30>; layer = <UIWindowLayer: 0x282ba4560>> <example.LightNavigationViewController: 0x107830800> rootController?.presentedViewController: Optional(<UIImagePickerController: 0x1078f1e00>) presentingViewController : nil
So:
/// Returns the top most view controller from given view controller's stack. open class func topMost(of viewController: UIViewController?) -> UIViewController? { // presented view controller if let presentedViewController = viewController?.presentedViewController { return self.topMost(of: presentedViewController) } ....
Then topMost will return PUPhotoPickerHostViewController instead SampleViewController.
Can you please share a sample project so that I can reproduce the bug?