Skip to content

Native embedded CollectionView is twice the screen width on iOS #24537

Closed Answered by JRosanowski
JRosanowski asked this question in General
Discussion options

You must be logged in to vote

It was actually an issue with my embedding code. I wasn't setting the frame of the ViewController created from the ContentPage.

public override void ViewDidLoad()
{
 base.ViewDidLoad();
   
 MyPage page = new();
 _pageViewController = page.ToUIViewController(AppDelegate.MauiContext);
 AddChildViewController(_pageViewController);
 View.AddSubview(_pageViewController.View);
 pageViewController.DidMoveToParentViewController(this);
}

public override void ViewDidLayoutSubviews()
 {
   base.ViewDidLayoutSubviews();
   // *** Must set the frame!!!
   _pageViewController.View.Frame = new CGRect(0, 0, View.Frame.Width, View.Frame.Height);
 }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JRosanowski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant