I have a View which contains a ScrollView. This Scrollview contains a UIView (called ContentView), which in turn has two subviews I'd like to scroll between.
Runtime, these are the values for the various views:
ContentView (inside the UIScrollView):
Width: 640
Height: 568
subView (UIView) inside the ContentView:
1
X: 0
Y: 0
Width: 320
Height: 568
2
X: 320
Y: 0
Width: 320
Height: 568
ScrollView:
Width: 320
Height: 568
ContentSize:
Width: 640
Height: 568
I add the subviews to the content view programatically (using a for loop) and then change the Bounds
of the ContentView and ContentSize
of the ScrollView accordingly, like so:
for (var i = 0; i < 2; i++) {
var page = ViewModel.Items[i];
var pageView = CreatePage(page);
pageView.Frame = new CGRect(View.Bounds.Width*i, 0, View.Bounds.Width, View.Bounds.Height);
ContentView.Add (pageView);
}
ContentView.Frame = new CGRect (0, 0, View.Bounds.Width * 2, View.Bounds.Height);
ScrollView.ContentSize = new CGSize (ContentView.Bounds.Width, ContentView.Bounds.Height);
When I load the application, this is what I get:
Just one of the subviews with no scrolling enabled. How can I get the horizontal scrolling working properly?
Thanks for any replies! :-)