I have a UIContainerView with Frame = {X=20,Y=88,Width=728,Height=660} and a UIScrollView embedded inside it.
The UIScrollView reports Frame = {X=0,Y=0,Width=768,Height=960} that results in an offset of 40 (the section in gold) in the width when paging the UIScrollView. It results in the following output having paged once to the left:
However, ContentSizeForViewInPopover reports the expected Frame size = {Width=728, Height=660}. How can I correct the UIScrollView frame to have the correct size?
Here is the code for ViewDidLoad() of the embedded UIViewController:
var pages = PageControl.Pages = 2;
Console.WriteLine("ScrollView Frame: {0}", ScrollView.Frame);
for(int i = 0; i < pages; i++)
{
RectangleF frame
frame.X = ScrollView.Frame.Width * i; // expected {728 * i} but is {768 * i}
frame.Y = 0;
frame.Size = ScrollView.Frame.Size;
Console.WriteLine("Subview frame: {0}", frame);
ScrollView.AddSubview(
new UIView(frame) {
Bounds = frame,
BackgroundColor = GetRandomColor()
});
}
ScrollView.ContentSize = new SizeF(ScrollView.Frame.Width * pages, ScrollView.Frame.Height);
Console.WriteLine("ScrollView ContentSize = {0}", ScrollView.ContentSize);