maui
maui copied to clipboard
iOS: UseSafeArea is ignored when root-element is a ScrollView
Description
I am having a ContentPage where the SafeArea is enabled.
<ContentPage xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
ios:Page.UseSafeArea="False">
</ContentPage>
Using a ScrollView as a root-element, the SafeArea is ignored.
Wrapping the ScrollView inside a Grid leads to the desired result (SafeArea is respected):
Steps to Reproduce
ScrollView as root-element (SafeArea is ignored)
<ContentPage>
<ScrollView>
<VerticalStackLayout>
<!-- place enough content here to make the content extend the vertical size of the screen -->
</VerticalStackLayout>
</ScrollView>
</ContentPage>
Grid as a root-element (SafeArea is respected)
<ContentPage>
<Grid>
<ScrollView>
<VerticalStackLayout>
<!-- place enough content here to make the content extend the vertical size of the screen -->
</VerticalStackLayout>
</ScrollView>
</Grid>
</ContentPage>
Link to public reproduction project repository
n/a
Version with bug
7.0.86
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 16.4
Did you find any workaround?
Wrapping the ScrollView inside a Grid-element. Performance-wise, this is a bad solution, of course.
Relevant log output
No response
I just noticed, that the same error occurs when using a CollectionView as the root-element inside a ContentPage.
#15809
We see this issue in our App as well with MAUI version 7.0.92.
Because of this we cannot use the On<iOS>().SetUseSafeArea(false); setting right now.
This is because ScrollView doesnt have the property IgnoreSafeArea, which is set to default to False for Layouts like Grid. I openened an issue here #16360
see also here #12417 , here #16398 , here #12823 and also potentially this one #15460
#15163
Are you able to try this again with a nightly build? https://github.com/dotnet/maui/wiki/Nightly-Builds
Are you able to try this again with a nightly build? https://github.com/dotnet/maui/wiki/Nightly-Builds
This issue is somewhat "Fixed" in the latest SR1 by the following PR. The UIScrollView now correctly takes https://developer.apple.com/documentation/uikit/uiscrollview/2902261-contentinsetadjustmentbehavior into account. By default UIScrollView has this property set to "Automatic" which means the UIScrollView itself will occupy the DangerZone but the content inset will be set to the area outside of the DangerZone. The problem that still existsis that you can't turn off the contentinsetadjustmentbehavior from the xplat level.
That being said, the UIScrollView in SR1 will now layout correctly based on what the contentinsetadjustmentbehavior is set to, so if you change this value to NEVER on the UIScrollView then the content will layout all the way into the DangerZone.
Check out the docs here on how to customize https://learn.microsoft.com/en-us/dotnet/maui/user-interface/handlers/customize?view=net-maui-8.0
I think we can close this issue for now as a duplicate of https://github.com/dotnet/maui/issues/16360 which covers the scenario a bit more broadly.
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
Verified this issue with Visual Studio Enterprise 17.9.0 Preview 4. Still repro on iOS platform with steps. This bug may duplicate with #16360
Any update on this issue?
Any update on this issue?
Any update on this issue? This is a priority for us.
Please provide a high priority for this issue.
Any update on this issue?
Any update on this issue?
Any workaround for this issue? Please provide a high priority for this issue.