本文整理汇总了C#中UIPickerView.Select方法的典型用法代码示例。如果您正苦于以下问题:C# UIPickerView.Select方法的具体用法?C# UIPickerView.Select怎么用?C# UIPickerView.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIPickerView
的用法示例。
在下文中一共展示了UIPickerView.Select方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Selected
public override void Selected(UIPickerView picker, nint row, nint component)
{
if(component == 0 && row > picker.SelectedRowInComponent(1))
{
picker.Select(row, 1, true);
}
if(component == 1 && row < picker.SelectedRowInComponent(0))
{
picker.Select(row, 0, true);
}
}
示例2: Selected
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
model = new CounterPickerDataModel(model.Counter);
var vc = new MyViewController (this) {
Autorotate = dvc.Autorotate
};
counterPicker = CreatePicker ();
counterPicker.Frame = PickerFrameWithSize (counterPicker.SizeThatFits (SizeF.Empty));
counterPicker.Model = model;
for (int d = 0; d < model.Items.Count; d++) {
counterPicker.Select(model.SelectedIndex[d], d, true);
}
vc.View.BackgroundColor = UIColor.Black;
vc.View.AddSubview (counterPicker);
dvc.ActivateController (vc);
}
示例3: PickerAlert
public PickerAlert(string[] values, int currentSelected, Action<int> selected)
: base(new RectangleF(0, 0, 320f, 480f))
{
AutosizesSubviews = true;
this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
_values = values;
_currentSelected = currentSelected;
_selected = selected;
_pickerView = new UIPickerView();
_pickerView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
_pickerView.ShowSelectionIndicator = true;
_pickerView.Model = new PickerModel(values);
_pickerView.BackgroundColor = UIColor.FromRGB(244, 244, 244);
_pickerView.Select(currentSelected, 0, false);
_toolbar = new UIToolbar();
_toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;
_toolbar.Items = new UIBarButtonItem[]
{
new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (s, e) => {
_selected(_pickerView.SelectedRowInComponent(0));
Dismiss();
})
};
_innerView = new UIView(new RectangleF(0, Frame.Height, Frame.Width, 44f + _pickerView.Frame.Height));
_innerView.AutosizesSubviews = true;
_innerView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;
_toolbar.Frame = new RectangleF(0, 0, Frame.Width, 44f);
_innerView.Add(_toolbar);
_pickerView.Frame = new RectangleF(0, 44f, Frame.Width, _pickerView.Frame.Height);
_innerView.Add(_pickerView);
Add(_innerView);
}
示例4: Selected
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
model = new TimePickerDataModel(model.Time);
var vc = new MyViewController (this) {
Autorotate = dvc.Autorotate
};
counterPicker = CreatePicker ();
counterPicker.Frame = PickerFrameWithSize (counterPicker.SizeThatFits (SizeF.Empty));
counterPicker.Model = model;
for (int d = 0; d < model.Times.Count; d++) {
counterPicker.Select(model.SelectedIndex[d], d, true);
}
// pass value changed
model.ValueChanged += delegate {
if (this.ValueChanged != null) {
Value = model.FormatValue ();
this.ValueChanged (this, new EventArgs ());
}
};
vc.View.BackgroundColor = backgroundColor;
vc.View.AddSubview (counterPicker);
dvc.ActivateController (vc);
}
示例5: CreatePicker_PrivacyLevels
private void CreatePicker_PrivacyLevels()
{
// Create Picker
var picker = new UIPickerView ();
picker.Model = new PrivacyLevelViewModel(prayerService.PrivacyLevels);
picker.ShowSelectionIndicator = true;
// Create Toolbar for Picker
UIToolbar toolbar = new UIToolbar ();
toolbar.BarStyle = UIBarStyle.Black;
toolbar.Translucent = true;
toolbar.SizeToFit ();
// Event Handler for Done Button on Drop Down
UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,(s,e) =>
{
foreach (UIView view in this.View.Subviews)
{
if (view.IsFirstResponder)
{
UITextField textview = (UITextField)view;
var pickerItem = picker.Model as PrivacyLevelViewModel;
textview.Text = pickerItem.SelectedItem.Level;
textview.ResignFirstResponder ();
}
}
} );
toolbar.SetItems (new UIBarButtonItem[]{doneButton},true);
// Set Textbox to use Picker
txtPrivacy.InputView = picker;
txtPrivacy.InputAccessoryView = toolbar;
// Select Item currently in Textbox
txtPrivacy.TouchDown += (sender, e) => {
UITextField field = (UITextField)sender;
var index = 0;
if (field.Text != ""){
index = prayerService.PrivacyLevels.FindIndex (a => a.Level == field.Text);
}
picker.Select (index, 0, true);
} ;
}
示例6: actionChangeKey
partial void actionChangeKey(NSObject sender)
{
_actionSheet = new UIActionSheet("Title", null, string.Empty, string.Empty, null);
var pickerView = new UIPickerView(new RectangleF(0, 44, 320, 300));
pickerView.ShowSelectionIndicator = true;
pickerView.WeakDelegate = this;
var toolbar = new UIToolbar(new RectangleF(0, 0, 320, 44));
toolbar.BarStyle = UIBarStyle.Black;
UIBarButtonItem flexSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
var button = new UIButton(UIButtonType.Custom);
button.SetTitle("Done", UIControlState.Normal);
button.Layer.CornerRadius = 8;
button.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
button.Font = UIFont.FromName("HelveticaNeue-Bold", 12.0f);
button.Frame = new RectangleF(0, 20, 60, 30);
button.TouchUpInside += (sender2, e) => {
int key = _keys[pickerView.SelectedRowInComponent(0)].Item1;
OnChangeKey(key);
_actionSheet.DismissWithClickedButtonIndex(0, true);
};
var btnDone = new UIBarButtonItem(button);
toolbar.SetItems(new UIBarButtonItem[2] { flexSpace, btnDone }, true);
_actionSheet.AddSubview(toolbar);
_actionSheet.AddSubview(pickerView);
_actionSheet.ShowInView(UIApplication.SharedApplication.KeyWindow);
_actionSheet.Bounds = new RectangleF(0, 0, 320, 344);
int index = _keys.IndexOf(_currentKey);
pickerView.Select(index, 0, false);
}
示例7: UpdateSelectedItems
/// <summary>
/// Updates the selected items.
/// </summary>
/// <param name="picker">Picker.</param>
/// <param name="value">Value.</param>
public void UpdateSelectedItems(UIPickerView picker,object value)
{
if (value == null)
SelectedItems = null;
if (value is object[])
{
var vals = (object[])value;
var aMsg = String.Empty;
for (int index = 0; index < vals.Length; index++)
{
var theVal = vals[index];
if (mDataDict.Count == 0)
return;
var aList = mDataDict[index];
if (theVal is int)
{
//index of the selected item
var iVal = (int)theVal;
if (iVal < aList.Items.Count
&& iVal >= 0)
{
var aItem = aList.Items[iVal];
aMsg += aItem.DisplayValue + mTableViewCell.SeperatorCharacter;
}
picker.Select(iVal,index,true);
}
else if (theVal is string)
{
//selected value of the selected item
var sVal = (string)theVal;
foreach (var aItem in aList.Items)
{
if (aItem.SelectedValue != null
&& aItem.SelectedValue is String)
{
if (((string)aItem.SelectedValue).ToLower().Equals(sVal.ToLower()))
{
picker.Select(aList.Items.IndexOf(aItem),index,true);
aMsg += aItem.DisplayValue + mTableViewCell.SeperatorCharacter;
}
}
else if (aItem.SelectedValue != null)
{
if (aItem.SelectedValue == theVal)
{
picker.Select(aList.Items.IndexOf(aItem),index,true);
aMsg += aItem.DisplayValue + mTableViewCell.SeperatorCharacter;
}
}
}
}
}
if (aMsg.EndsWith(mTableViewCell.SeperatorCharacter))
aMsg = aMsg.Substring(0,aMsg.LastIndexOf(mTableViewCell.SeperatorCharacter));
mTableViewCell.RightLabel.Text = aMsg;
SelectedItems = vals;
}
}
示例8: UpdateSelection
public void UpdateSelection(UIPickerView uipv)
{
if(selectedInches > 0)
{
for(int i = 0; i < Inches.Length; i++)
{
if(Inches[i] == selectedInches.ToString())
{
uipv.Select(i, 0, true);
break;
}
}
}
if(selectedFraction != null)
{
for(int i = 0; i < Fractions.Length; i++)
{
if(Fractions[i] == selectedFraction.ToString())
{
uipv.Select(i, 1, true);
break;
}
}
}
}
示例9: CreateHoursField
private UIPickerView CreateHoursField()
{
var hoursField = new UIPickerView()
{
Frame = new CGRect(100, 200, View.Bounds.Width - 120, 40),
};
hoursField.Model = new TimesheetEntryHoursViewModel();
hoursField.Select(32, 0, true);
return hoursField;
}