Skip to content

Commit

Permalink
Resize internal content container when ScrollView content is resized (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hartez authored Aug 10, 2023
1 parent 2d762b0 commit afd0b7c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Core/src/Handlers/ScrollView/ScrollViewHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,25 +167,25 @@ static Func<Rect, Size> ArrangeScrollViewContent(Func<Rect, Size> internalArrang
{
return (rect) =>
{
var contentSize = internalArrange(rect);
SetContentSizeForOrientation(platformScrollView, platformScrollView.Bounds.Width, platformScrollView.Bounds.Height, scrollOrientation, contentSize);
if (container.Superview is UIScrollView scrollView)
{
// Ensure the container is at least the size of the UIScrollView itself, so that the
// cross-platform layout logic makes sense and the contents don't arrange outside the
// container. (Everything will look correct if they do, but hit testing won't work properly.)
var scrollViewBounds = scrollView.Bounds;
var containerBounds = container.Bounds;
var containerBounds = contentSize;
container.Bounds = new CGRect(0, 0,
Math.Max(containerBounds.Width, scrollViewBounds.Width),
Math.Max(containerBounds.Height, scrollViewBounds.Height));
container.Center = new CGPoint(container.Bounds.GetMidX(), container.Bounds.GetMidY());
}
var contentSize = internalArrange(rect);
SetContentSizeForOrientation(platformScrollView, platformScrollView.Bounds.Width, platformScrollView.Bounds.Height, scrollOrientation, contentSize);
return contentSize;
};
}
Expand Down

0 comments on commit afd0b7c

Please sign in to comment.