iOS Question My iTableView challenges - Please advice...

Discussion in 'iOS Questions' started by Mashiane, Jun 1, 2015.

  1. Mashiane

    Mashiane Expert Licensed User


    I am struggling with the iTableView a lot and kindly need some advice. I have defined my pages in code modules...

    1. Where is the best location to initialize an iTableView? Inside pg.IsInitialized or outside? If outside, is that after navControl.ShowPage in your Show sub or just before?
    2. What is the best location to load items to the iTableView, in your Show sub? pg_resize, pg_appear? or somewhere else?
    3. On pg_resize event, is it compulsory / needed to .SetLayoutAnimated for iTableView? Can this event be left out when it comes to iTableViews or not?

    Here is my troublesome source code, can someone please advise?

    This followed this approach here:

    With my code, I have initialized my listviews inside pg.IsInitialized, when I call my show method for the page concerned, the first time the lists are loaded properly. After I click the back button and open the same page from the listview the items dont show on the iTableView anymore.
  2. Erel

    Erel Administrator Staff Member Licensed User

    Are the lists static? Or do you need to update the items dynamically?

    If the data is static then fill the list once when pg.IsInitialized is false.

    It is important. Otherwise the table view size will not be correct.
  3. Mashiane

    Mashiane Expert Licensed User

    A: 1 of the lists needs to be dynamic and the rest static. How do I refresh that one?

    There is a master iTableView where a user selects an entry and that opens another page with a listview. The first time this works fine, subsequent Show methods dont load the items in the iTableViews.
  4. Erel

    Erel Administrator Staff Member Licensed User

    The page is initialized once. If you load the items only when pg.IsInitialized is false then the items will be loaded once.
  5. Mashiane

    Mashiane Expert Licensed User

    'Code module

    Sub Process_Globals
    'These global variables will be declared once when the application starts.
       'Public variables can be accessed from all modules.
       Private pg As Page
    Private lstBD As TableView
    End Sub

    Sub pg_Appear
       Main.NavControl.ToolBarVisible = 
    End Sub

    Public Sub Show
       modBibleShow.strFrom = 
    If frmVerses.aloud.IsInitialized = True Then frmVerses.aloud.stop
       Main.NavControl.ToolBarVisible = 
    If pg.IsInitialized = False Then
         pg.RootPanel.Color = 
    End If
    End Sub

    Private Sub pg_Resize(Width As Int, Height As Int)
    End Sub

    Sub lstBD_SelectedChanged (SectionIndex As Int, Cell As TableCell)
    ' lets open a dictionary item
       Dim sKey As String
       sKey = 
    "Bible Dictionary_" & Cell.tag
    "promise", sKey)
       modBibleShow.EachChapter = 
       modBibleShow.strFrom = 
       modBibleShow.strPromise = Cell.tag
    End Sub
    Sub RefreshBD()
       Dim sKey As String = iStateManager.GetSetting("dictionary")
    Dim dMap As Map = b4iMash.Table_ReadToMap(modBibleShow.SQLite,"BibleDictionary","Key",sKey)
    Dim sText As String = dMap.Get("text")
       pg.Title = 
    "Bible Dictionary - " & sText
    'b4iMash.ShowProgress("Loading bible dictionary...")
       Dim cur As ResultSet
       cur = b4iMash.Table_OpenRecordset(modBibleShow.SQLite, 
    "select [Key],Text from BibleDictionary where Parent = '" & sKey & "' order by Text")
    Do While cur.NextRow
    Dim sKey As String: sKey = cur.GetString("Key")
    Dim sText As String: sText = cur.GetString("Text")
         b4iMash.AddSingleLine2(lstBD, sText, sKey)
    End Sub
    This is an approach I have followed for most of the code in my page modules. The contents of the iTableView in all except 1 are static. This works on the initial Show sub when accessing it from another page. When I call Show again by clicking an iTableView item from the master dynamic iTableView, the items are not loaded for this module. The first post has a link to the source of this project. Can you please advise what I'm missing? Thanks.
  6. Erel

    Erel Administrator Staff Member Licensed User

    See my answer in the other thread you started.
  7. Mashiane

    Mashiane Expert Licensed User

    Hi Erel, thanks for the help, I found a solution in one of the questions by accident just right now. All I had to do was iTableView.ReloadAll after reading my records from the SQLite table and loading them to the iTableView. All is perfect now.

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice