// - returns: An `ActionCell` instance with the target value for the characteristic at the specified index path. UITableViewCell GetActionCell(UITableView tableView, NSIndexPath indexPath) { var cell = (ActionCell)tableView.DequeueReusableCell(actionCell, indexPath); var characteristic = ActionSetCreator.AllCharacteristics() [indexPath.Row]; NSObject target = ActionSetCreator.TargetValueForCharacteristic(characteristic); if (target != null) { cell.SetCharacteristic(characteristic, (NSNumber)target); } return(cell); }
// Removes the action associated with the index path. public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath) { if (editingStyle == UITableViewCellEditingStyle.Delete) { var characteristic = ActionSetCreator.AllCharacteristics() [indexPath.Row]; ActionSetCreator.RemoveTargetValueForCharacteristic(characteristic, () => { if (ActionSetCreator.ContainsActions) { tableView.DeleteRows(new [] { indexPath }, UITableViewRowAnimation.Automatic); } else { tableView.ReloadRows(new [] { indexPath }, UITableViewRowAnimation.Automatic); } }); } }
// returns: In the Actions section: the number of actions this set will contain upon saving. // In the Accessories section: The number of accessories in the home. public override nint RowsInSection(UITableView tableView, nint section) { switch ((ActionSetTableViewSection)(int)section) { case ActionSetTableViewSection.Name: return(base.RowsInSection(tableView, section)); case ActionSetTableViewSection.Actions: return(Math.Max(ActionSetCreator.AllCharacteristics().Length, 1)); case ActionSetTableViewSection.Accessories: return(displayedAccessories.Count); default: throw new InvalidOperationException("Unexpected `ActionSetTableViewSection` value."); } }