本文整理汇总了C#中UITextField.AddTarget方法的典型用法代码示例。如果您正苦于以下问题:C# UITextField.AddTarget方法的具体用法?C# UITextField.AddTarget怎么用?C# UITextField.AddTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UITextField
的用法示例。
在下文中一共展示了UITextField.AddTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
//.........这里部分代码省略.........
示例2: PrepareEntry
protected virtual void PrepareEntry(UITableView tableview){
SizeF size = _computeEntryPosition(tableview);
_entry = new UITextField (new RectangleF (size.Width+10, (ContentView.Bounds.Height-size.Height)/2-1, 320-size.Width, size.Height));
TextLabel.BackgroundColor = UIColor.Clear;
_entry.AutoresizingMask = UIViewAutoresizing.FlexibleWidth |
UIViewAutoresizing.FlexibleLeftMargin;
_entry.ValueChanged += delegate {
if (_element != null)
_element.Value = _entry.Text;
};
_entry.Ended += delegate {
if (_element != null)
_element.Value = _entry.Text;
};
_entry.AddTarget((object o, EventArgs r)=>{
if (_element != null)
_element.Value = _entry.Text;
}, UIControlEvent.EditingChanged);
_entry.ShouldReturn += delegate {
Element elementToFocusOn = null;
foreach (var c in ((Section)_element.Parent).Elements){
if (c == _element)
elementToFocusOn = c;
else if (elementToFocusOn != null && c is EntryElement)
elementToFocusOn = c as EntryElement;
}
if (elementToFocusOn != _element && elementToFocusOn!=null) {
var index = elementToFocusOn.GetIndexPath();
var cell = tableview.CellAt(index);
tableview.ScrollToRow(index, UITableViewScrollPosition.Bottom, true);
cell.BecomeFirstResponder();
}
else
_entry.ResignFirstResponder();
if (_entry.ReturnKeyType == UIReturnKeyType.Go) {
_element.FireGo(this, EventArgs.Empty);
}
return true;
};
_entry.Started += delegate {
EntryElement self = null;
var returnType = _element.ReturnKeyType;
if (returnType != UIReturnKeyType.Default) {
foreach (var e in (_element.Parent as Section).Elements){
if (e == _element)
self = _element;
else if (self != null && e is EntryElement)
returnType = UIReturnKeyType.Next;
}
}
_entry.ReturnKeyType = returnType;
};
ContentView.AddSubview (_entry);
}