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

[iOS] UIScrollView Custom Handler's Zoom View changes position after button click or resuming from OnSleep state #20632

Open
Takashi125 opened this issue Feb 16, 2024 · 3 comments
Labels
area-controls-scrollview ScrollView migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/iOS 🍎 t/bug Something isn't working
Milestone

Comments

@Takashi125
Copy link

Takashi125 commented Feb 16, 2024

Description

I'm currently porting our Xamarin.Forms application that has a custom ScrollViewer implementing UIKit's ScrollView. But there's a bug that whenever the screen's zoomed and the app resumes from a sleep state, the view changes its position, shrinks its ScrollHeight , and zooming out positions the page on the upper left of the screen.

Update: Pressing the button inside the grid while on zoomed state also produces the same bug.

Steps to Reproduce

  1. Load the repro project (including setting an app identifier if testing on a physical device)
  2. Start the application on an iOS device or simulator
  3. Pinch zoom in the app
  4. Go back to the home screen, then go back to the app
  5. ScrollView height shrinks, and when you pinch zoom out, the main page's offset moves to the upper left of the screen

Link to public reproduction project repository

https://github.com/Takashi125/UIScrollViewBugProj

Version with bug

7.0.101 , 8.0.3 GA

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17, iOS 15

Did you find any workaround?

No response

Relevant log output

No response

@Takashi125 Takashi125 added the t/bug Something isn't working label Feb 16, 2024
@samhouts samhouts added platform/iOS 🍎 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels Feb 16, 2024
@Eilon Eilon added the area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label Feb 21, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Mar 11, 2024
@Takashi125 Takashi125 changed the title [iOS] UIScrollView Custom Handler's Zoom View changes position after resuming from OnSleep state [iOS] UIScrollView Custom Handler's Zoom View changes position after button click or resuming from OnSleep state Apr 5, 2024
@Takashi125
Copy link
Author

Takashi125 commented Apr 26, 2024

Unfortunately, I wasn't able to figure out a workaround on a ScrollViewHandler. Instead, I reused XF's ScrollViewRenderer, and manually set the Frame of the ViewForZooming as a workaround. this eliminates the bug where the screen repositions itself off the screen after sleep or button tap.

            var frameSize = new CGSize(this.Width, this.Height);
            var nativeView = ((UIKit.UIView)zoomableSV.Handler.PlatformView);
            nativeView.Subviews[0].Frame = new CGRect(x: 0, y: 0, width: frameSize.Width , height: frameSize.Height);

@Eilon Eilon added area-controls-scrollview ScrollView and removed area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter labels May 14, 2024
@Cast324
Copy link

Cast324 commented Sep 19, 2024

Unfortunately, I wasn't able to figure out a workaround on a ScrollViewHandler. Instead, I reused XF's ScrollViewRenderer, and manually set the Frame of the ViewForZooming as a workaround. this eliminates the bug where the screen repositions itself off the screen after sleep or button tap.

            var frameSize = new CGSize(this.Width, this.Height);
            var nativeView = ((UIKit.UIView)zoomableSV.Handler.PlatformView);
            nativeView.Subviews[0].Frame = new CGRect(x: 0, y: 0, width: frameSize.Width , height: frameSize.Height);

We're experiencing this same issue. When were you setting the frame? In the backing class OnSizeAllocated?

@Takashi125
Copy link
Author

In our application, I only needed to adjust the native view's frame after adding child views inside the StackLayout contained within the ScrollViewer. This was necessary because rendering a UIScrollView using the ScrollViewRenderer does not automatically set the frame for the ViewForZooming child. It appears that in addition to setting the ViewForZooming, manually adjusting its frame is also required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-scrollview ScrollView migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants