iOS Question Problem with ExpandableTableView regeneration

pixsys

Member
Licensed User
Longtime User
Hello,
I'm using erel's example code posted in the ExpandableTableView thread. Everything works fine, but i can't seem to understand how to regenerate the view after deleting all the childrens.

B4X:
Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("1")
    NavControl.ShowPage(Page1)
    NavControl.ToolBarVisible = True
    etv.Initialize(Me, "etv")
    Page1.RootPanel.AddView(etv.View, 0, 0, 100%x, 100%y)
  
    initETV 'In the original example this subs's content followed here
End Sub


Sub initETV
  
    For i1 = 1 To 10
        Dim c As CustomCell
        c.Initialize
        c.Text = "Item #" & i1
        c.Children.Initialize
        If i1 Mod 2 = 0 Then
            CreateCustomItem(c)
            For i2 = 1 To 5
                Dim c2 As CustomCell
                c2.Initialize
                c2.Text = "Child #" & i2
                c.Children.Add(c2)
                c2.Children.Initialize
                If i2 Mod 2 = 0 Then
                    CreateCustomItem(c2)
                    For i3 = 1 To 3
                        Dim c3 As CustomCell
                        c3.Initialize
                        c3.Text = "Grandchild #" & i3
                        CreateCustomItem(c3)
                        c2.Children.Add(c3)
                    Next
                End If
            Next
        End If  
        etv.Root.Children.Add(c)
    Next
    etv.RefreshItems
End Sub


Sub Page1_BarButtonClick (Tag As String)
    Select Tag
        Case "ExpandAll"
            etv.ExpandAll
        Case "CollapseAll"
            etv.collapseAll

'i added these last 3 for debug purposes, and implemented them in the layout file
        Case "Init"
            initETV
        Case "Delete"
            etv.Root.Children.Clear
            etv.ExpandAll
        Case "Refresh"
            etv.tv.Clear
    End Select
End Sub

I split the initialization and population code, adding a couple test buttons. After calling "delete" or "refresh", and then "Init" ,the ExpandableTableView does not regenerate, showing just a blank screen.
The view is already there and initialized, so i figured repopulating it was enough


What is the correct way to do this?
 
Last edited:

pixsys

Member
Licensed User
Longtime User
I also noticed another thing: adding a breakpoint at the start of the population sub (and resuming execution as soon as that line is reached) breaks the ui generation on the xcode simulator, showing a blank screen.
Removing the breakpoint generates the ui just fine (still have the delete/regen issue in the OP thou)

Maybe an issue with the simulator? I'll get an iphone in a few days and test this, maybe on a physical device it will run just fine..

Can you create a small project with this code and upload it?
Done, the code is the same of your example, with just a modified layout and the population code split in another sub
 

Attachments

  • ExpandableTableView.zip
    43.8 KB · Views: 182
Upvote 0
Top