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

Support UIViewController contentScrollView #723

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lechuckcaptain
Copy link

@lechuckcaptain lechuckcaptain commented Mar 16, 2023

I added an optional argument to the .image snapshot strategy that try to retrieve the UIViewController.contentScrollView (when it's available).
This should improve the sizing of the target UIViewController in the case a UIScrollView is used.

This proposal should provide a better way of working around the issue #264.

@dhrushit-RIT
Copy link

Is there any update to this issue?

@maross
Copy link

maross commented Jul 17, 2023

Is there any update to this issue?

+1

Comment on lines +938 to +939
if #available(iOS 15.0, *) {
if computeScrollSize, let scrollView = viewController.contentScrollView(for: .top) {
Copy link

Choose a reason for hiding this comment

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

In some cases this is misleading, for example, computeScrollSize: true on the caller site, but without effect when the project's deployment target is less than iOS 15.

Having an alternative for backward compatibility that looks for the top-most or bottom-most(?) scrollView would be great.

Copy link
Author

Choose a reason for hiding this comment

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

It makes sense. Just to better understand, can you expand a little about what do you think should be the alternative for devices with target < iOS 15 ? Thanks!

Copy link

@chosa91 chosa91 Sep 26, 2023

Choose a reason for hiding this comment

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

I'm thinking about something that traverses through the subviews and returns the first (topmost) one which matches the predicate of view is UIScrollView.

https://stackoverflow.com/questions/32301336/swift-recursively-cycle-through-all-subviews-to-find-a-specific-class-and-appen
https://stackoverflow.com/questions/32151637/swift-get-all-subviews-of-a-specific-type-and-add-to-an-array/45297466

I'm not saying that these implementations are correct, so please use them with a grain of salt, but the idea is something like this.

Edit: The above is not going to be good, because we want to assess those at the current depth level, and only then go deeper.

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

Successfully merging this pull request may close these issues.

4 participants