iOSTable / iOSCustomTableCell / AddRow not working as expected

Hello Community,

I want to populate a table manually with text and graphic. For this I use iOSTable with a iOSCustomTableCell. I have only a few values so
I do not use a datasource.

I try to understand the usage of iOSTable and iOSCustomTableCell in a small test app.

I use the following code :

Table1.RemoveAll
Table1.AddSection("")

Dim cell As  iOSTableCellData = Table1.CreateCustomCell(GetTypeInfo(iOSCustomTableCell1))
Dim customcell As iOSCustomTableCell1 = iOSCustomTableCell1(cell.Control)

customcell.Label1.Text = "Test"
Table1.AddRow(0, cell)

customcell.Label1.Text = "Test 2"
Table1.AddRow(0, cell)

I expected to see 2 rows. In the first row “Test” and in the second Row “Test 2”.

I got one row with “Test 2”.

I have checked the examples but here the table is populated with a datasource.
The documentation refers partly to the example.

Did I miss something or missunderstood?

Regards

You need to create a new cell every time before you add it to the table. Reusing the same cell means you get the weird behavior you describe.

Look at the open event of my MainView for iOSKit for an example: https://github.com/kingj5/iOSKit/blob/master/ExampleViews/MainView.xojo_code

Also I recommend you use the IOSTableCellData interface to provide the cells and information. It will give you better performance and is the recommended way to approach using IOSTables.

Hello Jason,

thank you for your answer.

I will check your recommendation.

I updated my test app with the following code.

Table1.RemoveAll
Table1.AddSection("")

Dim cell1 As iOSTableCellData = Table1.CreateCustomCell(GetTypeInfo(iOSCustomTableCell1))
Dim customcell1 As iOSCustomTableCell1 = iOSCustomTableCell1(cell1.Control)

customcell1.Label1.Text = "Test"
Table1.AddRow(0, cell1)

Dim cell2 As iOSTableCellData = Table1.CreateCustomCell(GetTypeInfo(iOSCustomTableCell1))
Dim customcell2 As iOSCustomTableCell1 = iOSCustomTableCell1(cell2.Control)

customcell2.Label1.Text = "Test2"
Table1.AddRow(0, cell2)

Here I got now the expected result with “Test” in row 1 and and “Test 2” in row 2.

I have a further question but I will create another entry as my original question is answered.

Regards