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

🐛 Present view on keyWindow over iOS 17 #46

Conversation

SongJiyeon
Copy link
Contributor

I had a issue that when the view doesn't have the uiViewController, it just reset the binding item. And weirdly, this happens only in iOS 17.
So I present the view on the key window (not uiView.viewController), when in iOS 17.

Copy link

@tisohjung tisohjung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Owner

@stleamist stleamist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution, Jiyeon!

I'll release a new version after I apply the suggestions on the comments I left.

guard let presentingViewController = uiView.viewController else {
self.resetItemBinding()

if #available(iOS 17.0, *) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I think it would be nice to use your suggestion even on iOS 16 and earlier.

This guarantees that presentingViewController doesn't have a presentedViewController, which means the modal presentation ofSafariViewController will not be blocked by any other presentedViewController.

self.resetItemBinding()

if #available(iOS 17.0, *) {
if var topController = UIApplication.shared.windows.filter(\.isKeyWindow).first?.rootViewController {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An UIWindow instance is must be grabbed via uiView.window.

UIApplication.shared.windows is deprecated in iOS 15, and this will make an issue when there are two or more UIWindowScenes.

@stleamist stleamist self-assigned this Oct 29, 2023
@stleamist stleamist changed the base branch from develop to bug/ios-17-key-press-responder-issue October 29, 2023 15:32
@stleamist stleamist added bug Something isn't working duplicate This issue or pull request already exists labels Oct 29, 2023
@stleamist
Copy link
Owner

Relates to #41

@stleamist stleamist merged commit df7db51 into stleamist:bug/ios-17-key-press-responder-issue Oct 29, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants