Пример #1
0
 public UIComboBox(RectangleF rect) : base(rect)
 {
     this.BorderStyle = UITextBorderStyle.RoundedRect;
     pickerView       = new PickerView();
     this.TouchDown  += delegate {
         ShowPicker();
     };
     this.ShouldChangeCharacters += delegate {
         return(false);
     };
     pickerView.IndexChanged += delegate {
         var oldValue = this.Text;
         this.Text = pickerView.StringValue;
         if (ValueChanged != null && oldValue != Text)
         {
             ValueChanged(this, null);
         }
     };
     closeBtn = new UIButton(new RectangleF(0, 0, 31, 32));
     closeBtn.SetImage(UIImage.FromFile("Images/closebox.png"), UIControlState.Normal);
     closeBtn.TouchDown += delegate {
         HidePicker();
     };
     pickerView.AddSubview(closeBtn);
 }
		public UIComboBox(RectangleF rect) : base (rect)
		{
			this.BorderStyle = UITextBorderStyle.RoundedRect;
			pickerView = new PickerView();
			this.TouchDown += delegate {	
				ShowPicker();
			};
			this.ShouldChangeCharacters += delegate {
				return false;	
			};
			pickerView.IndexChanged += delegate {
				var oldValue = this.Text;
				this.Text = pickerView.StringValue;	
				if(ValueChanged!= null && oldValue != Text)
					ValueChanged(this,null);
					
			};
			closeBtn = new UIButton(new RectangleF(0,0,31,32));
			closeBtn.SetImage(UIImage.FromFile("Images/closebox.png"),UIControlState.Normal);
			closeBtn.TouchDown += delegate {
				HidePicker();
			};
			pickerView.AddSubview(closeBtn);
		}
Пример #3
0
        public void ShowPicker()
        {
            if (PickerShown != null)
            {
                PickerShown(this, null);
            }
            LayoutSubviews();
            pickerView.BringSubviewToFront(closeBtn);
            pickerVisible = true;
            var parentView  = ViewForPicker ?? this.Superview;
            var parentFrame = parentView.Frame;

            //closeView = new TapableView(parentView.Bounds);
            //closeView.Tapped += delegate{
            //	HidePicker();
            //};

            pickerView.Frame = pickerView.Frame.SetLocation(new PointF(0, parentFrame.Height));

            UIView.BeginAnimations("slidePickerIn");
            UIView.SetAnimationDuration(0.3);
            UIView.SetAnimationDelegate(this);
            UIView.SetAnimationDidStopSelector(new Selector("fadeInDidFinish"));
            //parentView.AddSubview(closeView);
            parentView.AddSubview(pickerView);
            var tb = new UITextField(new RectangleF(0, -100, 15, 25));

            pickerView.AddSubview(tb);
            tb.BecomeFirstResponder();
            tb.ResignFirstResponder();
            tb.RemoveFromSuperview();


            pickerView.Frame = pickerView.Frame.SetLocation(new PointF(0, parentFrame.Height - pickerView.Frame.Height));
            UIView.CommitAnimations();
        }