Example #1
0
        public void pickerViewModel(UITextField textFieldItem, List<string> segmentosStrings, UIButton button)
        {
            PickerModel picker_model_Segmentos = new PickerModel (segmentosStrings);
            UIPickerView picker_Segmentos = new UIPickerView ();
            picker_Segmentos.Model = picker_model_Segmentos;
            picker_Segmentos.ShowSelectionIndicator = true;

            UIToolbar toolbar = new UIToolbar ();
            toolbar.BarStyle = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit ();

            var tapRecognizer = new UITapGestureRecognizer ();

            tapRecognizer.AddTarget(() => {
                Console.WriteLine("CLICK");
            });

            tapRecognizer.NumberOfTapsRequired = 2;
            tapRecognizer.NumberOfTouchesRequired = 1;

            picker_Segmentos.AddGestureRecognizer(tapRecognizer);

            UIBarButtonItem doneButton = new UIBarButtonItem ("Done", UIBarButtonItemStyle.Bordered,(s, e) => {
                //				Console.WriteLine((int)picker_Segmentos.SelectedRowInComponent);
                Console.WriteLine(picker_model_Segmentos.values[(int)picker_Segmentos.SelectedRowInComponent(0)].ToString ());
                textFieldItem.Text = picker_model_Segmentos.values[(int)picker_Segmentos.SelectedRowInComponent(0)].ToString ();
                if(button.Tag == 2 || button.Tag == 3){
                    Console.WriteLine("longCode ButtonClicked");
                }

                textFieldItem.ResignFirstResponder ();
            });

            UIBarButtonItem cancelButton = new UIBarButtonItem ("cancel", UIBarButtonItemStyle.Bordered, (s, e) => {
                textFieldItem.ResignFirstResponder ();
            });
            toolbar.SetItems (new UIBarButtonItem[]{ doneButton, cancelButton }, true);
            toolbar.TintColor = UIColor.White;
            textFieldItem.InputView = picker_Segmentos;
            this.View.BackgroundColor = UIColor.Clear;
            textFieldItem.InputAccessoryView = toolbar;
            textFieldItem.AddGestureRecognizer (tapRecognizer);
        }
// Use For Actionsheet picker view
		public void loadAffiliatePickerView ()
		{
			List<String> segmentosStrings = new List<String> ();

			if (Constant.affiliateResponse != null) {
				for (int i = 0; i < Constant.affiliateResponse.data.Count; i++) {
					segmentosStrings.Add (Constant.affiliateResponse.data [i].name.ToString());
				}
			}

			picker_model_Segmentos = new PickerModel (segmentosStrings);
			picker_Segmentos = new UIPickerView ();
			picker_Segmentos.Model = picker_model_Segmentos;
			picker_Segmentos.ShowSelectionIndicator = true;

			UIToolbar toolbar = new UIToolbar ();
			toolbar.BarStyle = UIBarStyle.Black;
			toolbar.Translucent = true;
			toolbar.SizeToFit ();

			var tapRecognizer = new UITapGestureRecognizer ();

			tapRecognizer.AddTarget(() => { 
				Console.WriteLine("CLICK");
			});

			tapRecognizer.NumberOfTapsRequired = 2;
			tapRecognizer.NumberOfTouchesRequired = 1;

			picker_Segmentos.AddGestureRecognizer(tapRecognizer);

			UIBarButtonItem doneButton = new UIBarButtonItem ("Done", UIBarButtonItemStyle.Bordered,(s, e) => {
				//				Console.WriteLine((int)picker_Segmentos.SelectedRowInComponent);
				Console.WriteLine(picker_model_Segmentos.values[(int)picker_Segmentos.SelectedRowInComponent(0)].ToString ());
				affiliateName.SetTitle(picker_model_Segmentos.values[(int)picker_Segmentos.SelectedRowInComponent(0)].ToString (), UIControlState.Normal);
				affName.ResignFirstResponder ();

				for (int i = 0; i < Constant.affiliateResponse.data.Count; i++) {
					if(Constant.affiliateResponse.data [i].name.ToString() == picker_model_Segmentos.values[(int)picker_Segmentos.SelectedRowInComponent(0)].ToString ()){
						Constant.selectedAffialte.data = Constant.affiliateResponse.data[i];
					}
				}
			});

			UIBarButtonItem cancelButton = new UIBarButtonItem ("cancel", UIBarButtonItemStyle.Bordered, (s, e) => {
				affName.ResignFirstResponder ();
			});
			toolbar.SetItems (new UIBarButtonItem[]{ doneButton, cancelButton }, true);
			toolbar.TintColor = UIColor.White;
			affName.InputView = picker_Segmentos;
			this.View.BackgroundColor = UIColor.Black;
			affName.InputAccessoryView = toolbar;
			affName.AddGestureRecognizer (tapRecognizer);

		}