I am trying to put together a detailed view that can be changed, similar to the default iPhone contacts application.
I have a TableView of contacts, and I activate an editable detail view when I select a cell:
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
var editingSection = new Section ("Entity") {
new StringElement ("First name", "enter", _entity.FirstName),
new StringElement ("Last name", "enter", _entity.LastName)
};
var root = new RootElement("Entity Entry") {
editingSection
};
var entityEdit = new EntityEdit (root, true);
ConfigEdit (entityEdit);
dvc.ActivateController(entityEdit);
}
void ConfigEdit (DialogViewController dvc)
{
dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Edit, delegate {
dvc.TableView.SetEditing (true, true);
ConfigDone (dvc);
});
}
void ConfigDone (DialogViewController dvc)
{
dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Done, delegate {
dvc.TableView.SetEditing (false, true);
ConfigEdit (dvc);
});
}
The behavior I want to change is the ConfigEdit method. When I first show the view, the elements in the edit section should be StringElements. When I switch to edit mode, the elements must change to input elements because I want to delete a line or edit the text inside the element.
Is it possible? Is there a better approach to showing read-only items until editing mode is set?
source
share