Forum Xamarin Xamarin.iOS

UIScrollview prevent scroll vertically

I have a scrollview in a uinavigationcontroller that I want to prevent scrolling vertically.
By now I have almost accomplished this.
But the problem is that I have a clear StatusBar and therefore the scrollview starts 20px down from the top and I’m able to scroll the view up and down 20px.

I have set the scrollview to Bounces = false which prevents the scrollview to be dragged around.
But now I only need the set the scrollview to start 20px higher and not to be dragged 20 px down.

Anyone who knows how to accomplish this?

Best regards Morten


  • MortenKruse.9726MortenKruse.9726 DKBeta ✭✭
    edited August 2014

    Ok now I got it to start from the top under need the clear status bar.

    PointF contentOffset = ScrollView.ContentOffset; contentOffset.Y = 0; contentOffset.X = _list[CurrentPage].Frame.X; ScrollView.SetContentOffset(contentOffset, true);

    But I'm still able to scroll it 20 px down. I guess that I can do this becuse the statusbar is present at the top even though it is clear.
    How can I prevent the scrollview from scrolling vertically?

  • adamkempadamkemp USInsider, Developer Group Leader mod

    Scroll views will allow you to scroll if their content size is bigger than their bounds. If you want to disable scrolling vertically then make sure that the content size height is not bigger than the height of the scroll view's bounds.

Sign In or Register to comment.