xamarin ios UIPickerView

来源:互联网 发布:平板炒股软件 编辑:程序博客网 时间:2024/05/24 05:05
private void SetupPayoutsPicker()
        {
            List<string> payouts = new List<string> ();
            for (int i = 1; i < 201; i++) {
                payouts.Add (i.ToString ());
            }
            PickerModel model = new PickerModel (payouts);

            if (payouts != null && payouts.Count != 0) {
                getPayout = payouts [0];
            }
            model.PickerChanged += (sender, e) => {
                getPayout=e;
            };
            UIPickerView picker = new UIPickerView ();
            picker.ShowSelectionIndicator = true;
            picker.Model = model;

            UIToolbar toolbar = new UIToolbar ();
            toolbar.BarStyle = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit ();
            UIBarButtonItem doneButton = new UIBarButtonItem ("Done", UIBarButtonItemStyle.Done,
                (s, e) => {
                    txtPayouts.Text=getPayout;
                    txtPayouts.ResignFirstResponder();
                });
            toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true);

            txtPayouts.InputView = picker;
            txtPayouts.InputAccessoryView = toolbar;
        }
0 0
原创粉丝点击