How to use iOSMobileTable.RowEditingStyles.Insert properly

I have a multi-section table that is implementing the iOSMobileTableDataSourceEditing interface, and it is working fine in the sense that the delete and insert icons display on the table rows. I want the user to be able to add new rows to each section, so I need the insert icon to display somewhere, but not on an existing row, because those need the delete icons.

My current solution is right before the table enters edit mode, I create a empty, dummy data object in the data source for each section, reload the table sections, and give those dummy rows an insert icon. Upon leaving edit mode if any of the dummy data objects are still empty i remove them from the data sources and then reload the table section.

Is this the right way to use the insert icon? It just feels a bit clunky to me, but the Contacts app uses it that way when editing a contact.

The typical pattern in an iOS app is to put a + button on the right side of the toolbar with the “type” set to “Add” like this:

The advantage of using it this way is that it will automatically change for any localizations that might use a different icon.

I’ve been through several iterations of the UI, and that was one of the earlier tries. As far as presentation of the main screen, I really like the multi-section table and I would like to stick with it if I can.

The problem I had with a single toolbar Add button is that the different sections of the table have very different data types. So i would either need multiple Add buttons (one for each data type), or the single Add button would pop a chooser for the type of data you want to enter. I didn’t find either of those appealing. Ideally I would like an Add button for each table section, but I don’t think there is a built-in way to do that.

Another option I had considered was for each table section to have a single custom cell that contained a button for adding and another table to list the data for that section. Im guessing putting a table in a table cell might be frowned upon, but it does work.

Is this what you are trying to achieve?

Each section’s last row is a Textfield cell. When pressing the done button on the keyboard it will add the row.

RPReplay_Final1689610101

1 Like

That’s very close, but the data to be entered isn’t just simple text. Each row in my table is a summary of a class instance. There are probably 10 to 20 bits of data that need to be added, so an input screen will be required.

In that case you should have a row at the end of each section that will open a modal screen with everything needed for input.

The following example only uses one section, but the same could be done with an add entry in each section.

RPReplay_Final1689611924

Here is a link to the app if you want some inspiration (made with Xojo of course)

so… another option…

The section headers are technically UIViews. We could probably figure out a set of declares to put a button inside a header.

Edit: Well I typed that out loud… and now I’m wondering if I was right… just a sec.

Thanks @Jeremie_L, I’ll take a look!

1 Like

Yes you are right, Greg, using iOSMobileTableExtended it is already possible to use Custom Cells in place of section headers.

2 Likes

That’s what I was seeing in my head, and I think that would be my first choice…