iOS ListView layout bug

Attempted to scroll the table view to an out-of-bounds row (5) when there are only 5 rows in section 0. Table view: <UITableView: 0x103891400; frame = (0 48; 375 555); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x280a20b70>; backgroundColor = UIExtendedGrayColorSpace 0 1; layer = <CALayer: 0x2804de480>; contentOffset: {0, 0}; contentSize: {375, 280}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <AIComponentKit.ListView: 0x283d5b640>>. Irritants: ()
Note: You will not see another error reported for 5 seconds.

SimpleListView_iOS.aia (2.9 KB)

This is a listview with 5 items. Works perfectly on Android.
With the buttons you can select previous and next items.
The problem is that in the iOs version the highlighted element is one higher that the actually selected item.

Here are the blocks:


If you try to set the index to 5, the app crashes.

(tested on: https://iosbuildservertest.appinventor.mit.edu/ )

Try this one:
SimpleListView_iOS2.aia (3.0 KB)

1 Like

grafik

does not work on iOS.


@ewpatton

Hmm. Sounds like we aren't handling the 1-indexing properly in that component. It should be an easy fix.

1 Like

I don't have an iPhone so I can't test it. I want to try to fix it. You showed an error when you set SelectionIndex to 5. Was the list in ListView empty then? If not, how many elements did it have?

No.

5


But Evan has already explained the problem/cause.

1 Like

Yes, he explained it but there is no fix for it. From what I see, indexing is correct, the only problem is when the code wants to highlight the selected element with a color. After this error occurs, can you retrieve the correct index and selected element using the appropriate properties?

Thank you @Anke, for the perfect workaround!
I am making a training app for the sailing club and I was really stuck because of this error in iOS.

1 Like

@Patryk_F The indexing is correct, but the hightlighting is not, it is one ahead of the index. So, if you ask for the last elelement via the Next button, the app crashes.
@Anke's workaround is fine, I will update my real app using it, but it should be fixed I think.

Yes, it would match the error I found in the code.

Someone reported a different problem. When we set the listview to display text and images, and create data for the listview using CreateElement, the data is displayed incorrectly. Can you confirm that? Because I'm looking in the code, but I can't find the error that could cause this. Below is an example project. When you open the application, the list is filled from ListData, and when you click the button, it is filled from blocks. After selecting an item from the list, the main and detail values should be displayed.

TestListDataForIos.aia (9.7 KB)

What seems to happen in your example is that you cannot add new elements that are not just strings in iOS.
You can create an element, but there is no method to add it to the list.
As you know, there is a method to remove an element from a ListView. I think that similarly there should be an add element (at location). Android does not care, but iOS does.
Here is what happens if you press the "load from Blocks" button:

1 Like

Hmm, but in the sides I don't want to add items to the list, but replace the existing list. After pressing the button, the list created in the designer should be replaced with the one created in the blocks. However, as you can see, both lists are displayed somehow. It seems to me that a dictionary created in blocks using the CreateElement block is detected as a string and not as a dictionary.

As you can see, the dictionary is created as key = value, instead of key:value. I think this is the problem. But ListView should display only one type of data, not two at the same time. Could you test this project again?

TestListDataForIos2.aia (10.0 KB)

With this information I will be able to take a better look at the code in the ListView and fix it.

Press the button, and select item 2. Draw your conclusion!

  1. SetSelectionColor property in ListView doesn't work tried setting in Designer and Blocks.
  2. SearchFilter doesn't work.

Also any update regarding below error: