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

SafeArea insets for offscreen views #19

Open
lonsky opened this issue Nov 11, 2018 · 3 comments
Open

SafeArea insets for offscreen views #19

lonsky opened this issue Nov 11, 2018 · 3 comments
Assignees

Comments

@lonsky
Copy link

lonsky commented Nov 11, 2018

There is a problem with safe area insets for embedded views (viewControllers).

How to reproduce (you need phone or simulator with a notch):

  1. Fill stack view with views that take at least one screen in Portrait.
  2. Inside each view put at least one element that depends on safeArea (could be a label)
  3. Rotate to Landscape and scroll to bottom

See, that safe area is correct for those views that were visible and incorrect for those that weren't.

Seems like it's UIKit bug, but maybe you have a workaround for this issue.

the only solution i've found was inspired by this answer on SO:
https://stackoverflow.com/questions/46505999/using-a-stack-view-in-a-scroll-view-and-respecting-safe-area-insets?rq=1

- view
-- scroll view [constrained to superview]
--- view [constrained to superview]
---- stack view [constrained to safeArea]

but in this case you don't have TableView-like behaviour when background takes full width and content is located inside the safe area

safearea_issue

@marlimox marlimox self-assigned this Nov 11, 2018
@marlimox
Copy link
Owner

@lonsky thanks for the bug report. You’re right, it sounds like the safe area is somehow not being updated for these views that are offscreen. I’ll look into it when I get a chance.

One thing I’d be interested in seeing is whether the safeAreaInsetsDidChange() method is called on each view in the stack view, if so which views, and what the value of the safe area insets are after each call.

Depending on what the result of this is, perhaps AloeStackView could attempt to update each view when the safe area changes (specifically the ones that are offscreen that are not being updated). I’m not sure exactly what that would look like, but it could be an approach worth exploring.

Unfortunately I only have phone access at the moment, no computer access until next week, so I cannot debug this until then. Please feel free to share any details you learn in the meantime though. Thanks again!

@lonsky
Copy link
Author

lonsky commented Nov 11, 2018

hey Marli! thanks for your reply!

safeAreaInsetsDidChange() is invoked for visible views only (you can see debug message in console).

i've attached test project you can play with

TestAloeStackView.zip

@lonsky
Copy link
Author

lonsky commented Nov 11, 2018

also, i found this radar that sounds similar:
http://www.openradar.me/34426568

it is marked as resolved, but maybe for InterfaceBuilder+ContainerView case only

anyway, i've created the new radar for this. will post an update when i get 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