/// <summary> /// Dispose the specified disposing. /// </summary> /// <returns>The dispose.</returns> /// <param name="disposing">If set to <c>true</c> disposing.</param> protected override void Dispose(bool disposing) { if (disposing) { _model.UpdatePickerFromModel -= Model_UpdatePickerFromModel; DummyField.RemoveFromSuperview(); DummyField?.Dispose(); DummyField = null; _titleLabel?.Dispose(); _titleLabel = null; _model?.Dispose(); _model = null; _picker?.Dispose(); _picker = null; _command = null; } base.Dispose(disposing); }
void SetUpPicker() { _picker = new UIPickerView(); var width = UIScreen.MainScreen.Bounds.Width; _titleLabel = new UILabel(); _titleLabel.TextAlignment = UITextAlignment.Center; var toolbar = new UIToolbar(new CGRect(0, 0, (float)width, 44)) { BarStyle = UIBarStyle.Default, Translucent = true }; var cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (o, e) => { DummyField.ResignFirstResponder(); Select(_model.PreSelectedItem); }); var labelButton = new UIBarButtonItem(_titleLabel); var spacer = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (o, a) => { _model.OnUpdatePickerFormModel(); DummyField.ResignFirstResponder(); _command?.Execute(_model.SelectedItem); }); toolbar.SetItems(new[] { cancelButton, spacer, labelButton, spacer, doneButton }, false); DummyField.InputView = _picker; DummyField.InputAccessoryView = toolbar; _model = new TextPickerSource(); _picker.Model = _model; _model.UpdatePickerFromModel += Model_UpdatePickerFromModel; }