Hello @Ertan Dagistanli ,
It is caused by the ContentSize of UIScrollview in native iOS, the height of s1
/s2
/s3
becomes 0 when you set IsVisible = false
, so you could change the height of ContentSize
of UIScrollview
on iOS.
First, you should use native iOS namespace:
#if IOS
using UIKit;
#endif
Then, you can get the native control (UIScrollview) via Handler with MAUI and set the ContentSize
property. After that, you can deal with the IsVisible
logic, and change the height, I define a bool
field for testing the open/close effect, you can refer to the following code:
void TapGestureRecognizer_Tapped(System.Object sender, System.EventArgs e)
{
s1.IsVisible = !s1.IsVisible;
s2.IsVisible = !s2.IsVisible;
s3.IsVisible = !s3.IsVisible;
MessagingCenter.Send<NewScrollowPage>(this, "hi");// trigger this method, send message to change height
}
Subscribe the message in ContentPage
public partial class NewScrollowPage : ContentPage
{
public NewScrollowPage()
{
InitializeComponent();
bool isOpen = false;
Microsoft.Maui.Handlers.ScrollViewHandler.Mapper.AppendToMapping("MyCustom", (Handler, View) => {
MessagingCenter.Subscribe<NewScrollowPage>(this, "hi", (sender) => {
#if IOS
UIScrollView scrollView = Handler.PlatformView;
var height = scrollView.ContentSize.Height;
isOpen = !isOpen;// you can set different height according to your needs, you should decrease/increase the height when you set IsVisible to false/true.
scrollView.ContentSize = new CoreGraphics.CGSize(scrollView.ContentSize.Width, height+ (isOpen?300:-300));
#endif
});
});
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.