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

页面不能跳转的bug #116

Open
fooval-shen opened this issue Dec 11, 2018 · 4 comments
Open

页面不能跳转的bug #116

fooval-shen opened this issue Dec 11, 2018 · 4 comments

Comments

@fooval-shen
Copy link

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

@miku1958
Copy link

miku1958 commented Mar 26, 2019

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

@devxoul
Copy link
Owner

devxoul commented Apr 2, 2019

Does #110 fix this issue?

@KennethLaw
Copy link

KennethLaw commented Jul 4, 2019

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.

@devxoul
Copy link
Owner

devxoul commented Sep 7, 2019

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

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

No branches or pull requests

4 participants