コード例 #1
0
        public void EditingEnded(UITextField textField)
        {
            NSIndexPath indexPath = IndexPathForView(textField);

            if (indexPath.Row > 0)
            {
                // Edit the item in place.
                ListItem item = List[indexPath.Row - 1];

                // If the contents of the text field at the end of editing is the same as it started, don't trigger an update.
                if (item.Text != textField.Text)
                {
                    item.Text = textField.Text;

                    TriggerNewDataForWidget();

                    // Notify the document of a change.
                    document.UpdateChangeCount(UIDocumentChangeKind.Done);
                }
            }
            else if (textField.Text.Length > 0)
            {
                // Adds the item to the top of the list.
                ListItem item          = new ListItem(textField.Text);
                int      insertedIndex = List.InsertItem(item);

                // Update the edit row to show the check box.
                ListItemCell itemCell = (ListItemCell)TableView.CellAt(indexPath);
                itemCell.CheckBox.Hidden = false;

                // Insert a new add item row into the table view.
                TableView.BeginUpdates();

                NSIndexPath targetIndexPath = NSIndexPath.FromRowSection(insertedIndex, 0);
                TableView.InsertRows(new NSIndexPath[] { targetIndexPath }, UITableViewRowAnimation.Automatic);

                TableView.EndUpdates();

                TriggerNewDataForWidget();

                // Notify the document of a change.
                document.UpdateChangeCount(UIDocumentChangeKind.Done);
            }
        }
コード例 #2
0
        void ConfigureListItemCell(ListItemCell itemCell, int row)
        {
            itemCell.TextField.Font         = UIFont.PreferredBody;
            itemCell.TextField.WeakDelegate = this;

            if (row == 0)
            {
                // Configure an "Add Item" list item cell.
                itemCell.TextField.Placeholder = "Add Item";
                itemCell.CheckBox.Hidden       = true;
            }
            else
            {
                ListItem item = List[row - 1];

                itemCell.Completed      = item.IsComplete;
                itemCell.TextField.Text = item.Text;
            }
        }
コード例 #3
0
		void ConfigureListItemCell(ListItemCell itemCell, int row)
		{
			itemCell.TextField.Font = UIFont.PreferredBody;
			itemCell.TextField.WeakDelegate = this;

			if (row == 0) {
				// Configure an "Add Item" list item cell.
				itemCell.TextField.Placeholder = "Add Item";
				itemCell.CheckBox.Hidden = true;
			} else {
				ListItem item = List[row - 1];

				itemCell.Completed = item.IsComplete;
				itemCell.TextField.Text = item.Text;
			}
		}