public override void ViewDidLoad() { saveButton.TouchUpInside += SaveExpense; // Use a picker view to select our category choices. categoryPicker = new UIPickerView(); categoryPicker.Model = pickerData = new TextFieldPickerData(categoryText, new[] { "Lodging", "Meal", "Transportation", "Other" }); categoryText.InputView = categoryPicker; // Use a Toolbar to add a "Done" button to dismiss the picker. pickerToolbar = new UIToolbar { BarTintColor = UIColor.White, Translucent = false, }; doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => categoryText.ResignFirstResponder()); var flexibleSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null); pickerToolbar.Items = new [] { flexibleSpace, doneButton }; pickerToolbar.SizeToFit(); categoryText.InputAccessoryView = pickerToolbar; // Update the UI with the selected expense. OnUpdateDetails(); }
public override void ViewDidDisappear(bool animated) { // Get rid of things we created manually. categoryPicker.Dispose(); categoryPicker = null; pickerToolbar.Dispose(); pickerToolbar = null; doneButton.Dispose(); doneButton = null; pickerData.Dispose(); pickerData = null; }