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

When UIDocumentPickerViewController is displayed and hidden, useSafeAreaFrame returns an incorrect result #506

Open
suiyunpiaoliu opened this issue Jun 21, 2024 · 7 comments

Comments

@suiyunpiaoliu
Copy link

In iOS systems, when UIDocumentPickerViewController is displayed, useSafeAreaFrame returns the correct result, but when UIDocumentPickerViewController is hidden, the result returned by useSafeAreaFrame is not restored

@jacobp100
Copy link
Collaborator

What does the frame change to when it’s presented?

@suiyunpiaoliu
Copy link
Author

On iPhone 15 Pro, before displaying UIDocumentPickerViewController, useSafeAreaFrame returns {width: 375, height: 812, x: 0, y: 0}, and when UIDocumentPickerViewController is displayed, it returns {y: 44, width: 343, height: 742.7093333333333, x: 16}, But when UIDocumentPickerViewController is hidden, the result is not restored

@jacobp100
Copy link
Collaborator

Gotta be honest I’m not sure why the frame changes 😅 are the insets correct?

@suiyunpiaoliu
Copy link
Author

insets didn't change when the UIDocumentPickerViewController trigger

@jacobp100
Copy link
Collaborator

This is sort of what I'd expect. Trying to get the frame in real time is quite difficult since iOS doesn't give you a way to do this. I don't particularly like the useSafeAreaFrame API because we can't handle every single case. What are you trying to achieve here? I might be able to give you some alternatives

@suiyunpiaoliu
Copy link
Author

Thanks, i modified the code of react-native-safe-area-context locally.
Add the following code to the init of RNCSafeAreaProvider. m
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(invalidateSafeAreaInsets) name:@"UIWindowFrameDidChange" object:nil];

And sent this notification when UIDocumentPickerViewController is hidden

@jacobp100
Copy link
Collaborator

We already check for a few of these cases - like keyboards. If you want to submit a PR, I'm pretty sure we'd be able to merge it

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

2 participants