C# 如何制作垂直滚动视图Xamarin

C# 如何制作垂直滚动视图Xamarin,c#,xamarin,uiscrollview,xamarin.ios,C#,Xamarin,Uiscrollview,Xamarin.ios,我正在尝试在Xamarin(iOS)中创建一个垂直滚动视图。滚动视图垂直上下滚动,但当我用按钮填充它时,它们是水平添加的。我是Xamarin的新手,他们给出的唯一例子是水平滚动视图。提前感谢这是我的代码: nfloat h = 50.0f; nfloat w = 150.0f; nfloat padding = 10.0f; scrollView = new UIScrollView { Frame = new CGRe

我正在尝试在Xamarin(iOS)中创建一个垂直滚动视图。滚动视图垂直上下滚动,但当我用按钮填充它时,它们是水平添加的。我是Xamarin的新手,他们给出的唯一例子是水平滚动视图。提前感谢这是我的代码:

    nfloat h = 50.0f;
    nfloat w = 150.0f;
    nfloat padding = 10.0f;

    scrollView = new UIScrollView
        {

            Frame = new CGRect(0, 100, View.Frame.Width, View.Frame.Height),
            ContentSize = new CGSize(View.Frame.Width,View.Frame.Height*3),
            BackgroundColor = UIColor.White,
            AutoresizingMask = UIViewAutoresizing.FlexibleHeight
        };
    //This is in a separate area and there are a few more of these blocks of code
    var button = UIButton.FromType(UIButtonType.RoundedRect);
                        button.SetTitle(ln, UIControlState.Normal);
                        button.Frame = new CGRect(padding * (i + 1) + (i * w), padding, w, h);
                        button.TouchUpInside += Button2TouchUpInside;
                        scrollView.AddSubview(button);
                        buttons.Add(button);
    //then finally
    View.AddSubview(scrollView);

交换CGRect中的x和y<代码>填充,填充*(i+1)+(i*w)交换CGRect中的x和y<代码>填充,填充*(i+1)+(i*w)