Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added toolbar to input accessory

  • Loading branch information...
commit 09d9386a3694f5377c936bf1e8c22a409d088b69 1 parent 5962d26
@13daysaweek authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 MonoTouchUIPickerView/MonoTouchUIPickerViewViewController.cs
View
19 MonoTouchUIPickerView/MonoTouchUIPickerViewViewController.cs
@@ -60,6 +60,7 @@ public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientat
private void SetupPicker()
{
+ // Setup the picker and model
PickerModel model = new PickerModel(this.colors);
model.PickerChanged += (sender, e) => {
this.selectedColor = e.SelectedValue;
@@ -69,7 +70,25 @@ private void SetupPicker()
picker.ShowSelectionIndicator = true;
picker.Model = model;
+ // Setup the toolbar
+ UIToolbar toolbar = new UIToolbar();
+ toolbar.BarStyle = UIBarStyle.Black;
+ toolbar.Translucent = true;
+ toolbar.SizeToFit();
+
+ // Create a 'done' button for the toolbar and add it to the toolbar
+ UIBarButtonItem doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
+ (s, e) => {
+ this.ColorTextField.Text = selectedColor;
+ this.ColorTextField.ResignFirstResponder();
+ });
+ toolbar.SetItems(new UIBarButtonItem[]{doneButton}, true);
+
+ // Tell the textbox to use the picker for input
this.ColorTextField.InputView = picker;
+
+ // Display the toolbar over the pickers
+ this.ColorTextField.InputAccessoryView = toolbar;
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.