public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            //dismiss the keyboard on background touch
            View.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                FahrenheitField.ResignFirstResponder();
                HumidityField.ResignFirstResponder();
            }));

            //after editing, compute
            HumidityField.EditingDidEnd   += compute;
            FahrenheitField.EditingDidEnd += compute;
            HumiditySwitch.ValueChanged   += compute;

            //when slider value is changed, update UI
            WindSlider.ValueChanged += (sender, e) =>
            {
                WindSpeedLabel.Text = String.Format("Wind Speed (0-100 mph): {0}",
                                                    (int)WindSlider.Value);

                compute(sender, e);
            };
        }
示例#2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            //Check settings
            RefreshFields();
            //dismiss the keyboard on background touch
            View.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                FahrenheitField.ResignFirstResponder();
                HumidityField.ResignFirstResponder();
                compute(null, null);
            }));

            //after editing, compute
            HumidityField.EditingDidEnd   += compute;
            FahrenheitField.EditingDidEnd += compute;
            HumiditySwitch.ValueChanged   += compute;

            //when slider value is changed, update UI
            WindSlider.ValueChanged += (sender, e) =>
            {
                //lazy, clean up kmph/mph
                WindSpeedLabel.Text = Metric ? $"Wind Speed (0-100 kph) {WindSlider.Value}" :
                                      $"Wind Speed (0-100 mph) {WindSlider.Value}";

                compute(sender, e);
            };
        }