URLNavigator icon indicating copy to clipboard operation
URLNavigator copied to clipboard

页面不能跳转的bug

Open fooval-shen opened this issue 7 years ago • 4 comments

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

fooval-shen avatar Dec 11 '18 11:12 fooval-shen

这里的写法有问题, 正确的写法应该是: return self.topMost(of: self.sharedApplication?.delegate?.window??.rootViewController)

miku1958 avatar Mar 26 '19 03:03 miku1958

Does #110 fix this issue?

devxoul avatar Apr 02 '19 10:04 devxoul

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.

KennethLaw avatar Jul 04 '19 04:07 KennethLaw

Can you please share a sample project so that I can reproduce the bug?

devxoul avatar Sep 07 '19 14:09 devxoul