iOS Question xCustomListView problem [closed for now]

Discussion in 'iOS Questions' started by Didier9, Jun 24, 2018.

  1. Didier9

    Didier9 Active Member Licensed User

    I am trying to add a CustomListView to a B4i project.

    I am getting this error as soon as Page1_Resize() completes:

    Code:
    Application_Start
    Error occurred on line: 
    150 (CustomListView)
    Object was 
    not initialized (UILabel)
    Stack Trace: (
      CoreFoundation       <redacted> + 
    252
      libobjc.A.dylib      objc_exception_throw + 
    56
      CoreFoundation       <redacted> + 
    0
      LightController      -[B4IObjectWrapper object] + 
    152
      LightController      -[B4ILabelWrapper TextAlignment] + 
    40
      CoreFoundation       <redacted> + 
    144
      CoreFoundation       <redacted> + 
    284
      LightController      +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 
    1624
      LightController      -[B4IShell runMethod:] + 
    448
      LightController      -[B4IShell raiseEventImpl:method:args::] + 
    1640
     LightController      -[B4IShellBI raiseEvent:
    event:params:] + 1560
     LightController      +[B4IDebug delegate:::] + 
    80
     LightController      -[b4i_customlistview _createlabel::] + 
    432
     LightController      -[b4i_customlistview _insertattextitem::::] + 
    1304
     LightController      -[b4i_customlistview _addtextitem:::] + 
    744
     LightController      -[b4i_main _pagemain_resize::] + 
    5744
     CoreFoundation       <redacted> + 
    144
     CoreFoundation       <redacted> + 
    284
     LightController      +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 
    1624
     LightController      -[B4IShell runMethod:] + 
    448
     LightController      -[B4IShell raiseEventImpl:method:args::] + 
    2164
     LightController      -[B4IShellBI raiseEvent:
    event:params:] + 1560
     LightController      +[B4IObjectWrapper raiseEvent:::] + 
    300
     LightController      __
    30-[B4IPanelView layoutSubviews]_block_invoke + 900
     libdispatch.dylib    <redacted> + 
    24
     libdispatch.dylib    <redacted> + 
    16
     libdispatch.dylib    <redacted> + 
    1012
     CoreFoundation       <redacted> + 
    12
     CoreFoundation       <redacted> + 
    2272
     CoreFoundation       CFRunLoopRunSpecific + 
    552
     GraphicsServices     GSEventRunModal + 
    100
     UIKit                UIApplicationMain + 
    236
     LightController      main + 
    124
     libdyld.dylib        <redacted> + 
    4
    )
    The offending line is this:
    Code:
    Private Sub CreateLabel(txt As StringAs B4XView
        [...]
        lbl.TextAlignment = DesignerLabel.TextAlignment
        [...]
    End Sub
    called withing a function named CreateLabel()
    It looks like DesignerLabel is uninitialized when that line is executed.

    However, DesignerLabel is defined in a function named DesignerCreateView() which apparently is never called:
    Code:
    Public Sub DesignerCreateView (Base As Object, Lbl As     DesignerLabel = Lbl
        [...]
        DesignerLabel = Lbl
        [...]
    End Sub
    I have attached the project using this code.
    Thanks in advance for any help...
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    1. The first step is to remove CustomListView module and add are a reference to the internal xCustomListView library.

    2. You need to add CustomListView with the visual designer.

    3. Your PageMain_Resize is wrong. The Resize event can be called many times. You should never add views in that sub. You should use the visual designer instead.
     
  3. Didier9

    Didier9 Active Member Licensed User

    Thank you Erel, I will try 1 and 2 tonight.

    The reason I added the views in code is because there may be a variable number of controls per page, depending on screen physical size (at the moment, I am working with an iPad Mini Retina and an iPhone 6 plus), but I only know the screen size in the Resize event, so on smaller devices I may need multiple pages. I guess the solution is to declare all the views I might need in Application_Start, and locate them (and turn off those I do not need) in the Resize event?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    No. The solution is to correctly use the visual designer.

    Watch the visual designer and B4i/B4J - Resize event tutorials: https://www.b4x.com/etp.html
     
  5. Didier9

    Didier9 Active Member Licensed User

    This is on hold at the moment, I have solved my issue some other way, but I will get back to this later as I will need the CustomListView in the next phase of my project.
     
Loading...
  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