本文整理汇总了C#中UIDatePicker.AddTarget方法的典型用法代码示例。如果您正苦于以下问题:C# UIDatePicker.AddTarget方法的具体用法?C# UIDatePicker.AddTarget怎么用?C# UIDatePicker.AddTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIDatePicker
的用法示例。
在下文中一共展示了UIDatePicker.AddTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
//scrollView = stackView.Superview as UIScrollView;
//scrollView.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag;
//scrollView.ScrollEnabled = true;
// Set up Navigation Bar
var saveButton = new UIBarButtonItem (UIBarButtonSystemItem.Save, save);
var cancelButton = new UIBarButtonItem (UIBarButtonSystemItem.Cancel, cancel);
NavigationItem.Title = "New Medication:";
NavigationItem.RightBarButtonItem = saveButton;
NavigationItem.HidesBackButton = true;
NavigationItem.LeftBarButtonItem = cancelButton;
//NSNotificationCenter.DefaultCenter.AddObserver (this, new ObjCRuntime.Selector("keyboardDidAppear:"), UIKeyboard.DidShowNotification, null);
//NSNotificationCenter.DefaultCenter.AddObserver (this, new ObjCRuntime.Selector ("keyboardWillDissapear:"), UIKeyboard.WillHideNotification, null);
// Set up the date formatter
dateFormat = new NSDateFormatter();
dateFormat.DateStyle = NSDateFormatterStyle.None;
dateFormat.TimeStyle = NSDateFormatterStyle.Short;
// Set up new pet form
nameField = new UITextField();
nameField.Text = "Medication Name";
nameField.BorderStyle = UITextBorderStyle.RoundedRect;
nameField.ReturnKeyType = UIReturnKeyType.Done;
medTypeLabel = new UILabel ();
medTypeLabel.Text = "Type of Medication";
medTypeButton = new UIButton (UIButtonType.RoundedRect);
medTypeButton.AddTarget (editMedType, UIControlEvent.TouchUpInside);
medTypeButton.SetTitle ("Pill", UIControlState.Normal);
medTypeButton.TitleLabel.Font = medTypeButton.TitleLabel.Font.WithSize (medTypeLabel.Font.PointSize);
medTypePicker = new UIPickerView ();
medTypePicker.Delegate = new MedTypePickerDelegate (this);
medTypePicker.DataSource = new MedTypePickerDataSource ();
freqLabel = new UILabel ();
freqLabel.Text = "Frequency";
freqTextField = new UITextField ();
freqTextField.Text = "1";
freqTextField.KeyboardType = UIKeyboardType.NumberPad;
freqTextField.BorderStyle = UITextBorderStyle.RoundedRect;
freqTextField.Enabled = false;
freqTextField.AddTarget (freqTextFieldChanged, UIControlEvent.EditingDidEnd | UIControlEvent.EditingDidEndOnExit);
freqStepper = new UIStepper ();
freqStepper.Value = 1;
freqStepper.MinimumValue = 1;
freqStepper.Enabled = false;
freqStepper.AddTarget (freqStepperIncremented, UIControlEvent.ValueChanged);
UIStackView freqStackView = new UIStackView (new UIView[] { freqTextField, freqStepper });
freqStackView.Spacing = 8;
freqStackView.Axis = UILayoutConstraintAxis.Horizontal;
freqButton = new UIButton (UIButtonType.RoundedRect);
freqButton.SetTitle ("Daily", UIControlState.Normal);
freqButton.TitleLabel.Font = freqButton.TitleLabel.Font.WithSize (medTypeLabel.Font.PointSize);
freqButton.AddTarget (editFrequency, UIControlEvent.TouchUpInside);
freqPicker = new UIPickerView ();
freqPicker.Delegate = new MedFreqPickerDelegate (this);
freqPicker.DataSource = new MedFreqPickerDataSource ();
timePicker = new UIDatePicker ();
gregorian = new NSCalendar (NSCalendarType.Gregorian);
timePicker.Date = gregorian.DateBySettingsHour (9, 0, 0, NSDate.Now, NSCalendarOptions.MatchNextTime);
timePicker.Mode = UIDatePickerMode.Time;
timePicker.AddTarget (timePickerChanged, UIControlEvent.AllEvents);
UILabel timeLabel = new UILabel ();
timeLabel.Text = "Time";
timeButtons = new UIButton[1];
timeDates = new NSDate[1];
timeDates [0] = gregorian.DateBySettingsHour (9, 0, 0, NSDate.Now, NSCalendarOptions.MatchNextTime);
timeButtons [0] = new UIButton (UIButtonType.RoundedRect);
timeButtons [0].SetTitle ("9:00 AM", UIControlState.Normal);
timeButtons [0].AddTarget (openTimePicker, UIControlEvent.TouchUpInside);
timeStack = new UIStackView ();
timeStack.Alignment = UIStackViewAlignment.Leading;
timeStack.Distribution = UIStackViewDistribution.FillProportionally;
timeStack.Spacing = 5;
timeStack.Axis = UILayoutConstraintAxis.Vertical;
timeStack.AddArrangedSubview (timeLabel);
foreach (var button in timeButtons) {
timeStack.AddArrangedSubview (button);
}
timeStack.AddArrangedSubview (timePicker);
timePicker.Hidden = true;
dayLabel = new UILabel ();
dayLabel.Text = "Day";
dayLabel.Hidden = true;
dayButton = new UIButton (UIButtonType.RoundedRect);
var day = gregorian.GetComponentFromDate (NSCalendarUnit.Weekday, NSDate.Now);
dayButton.SetTitle (gregorian.WeekdaySymbols[day], UIControlState.Normal);
dayButton.AddTarget (openDayPicker, UIControlEvent.TouchUpInside);
dayButton.Hidden = true;
dayPicker = new UIDatePicker ();
dayPicker.Mode = UIDatePickerMode.Date;
dayPicker.MinimumDate = NSDate.Now;
dayPicker.MaximumDate = NSDate.Now.AddSeconds (604800);
//.........这里部分代码省略.........