iOS Question ViewPagerNative Crashes on iOS

EduardoElias

Well-Known Member
Licensed User
Longtime User
I have extracted the library from the b4xlib file and added to the app.

I have also added the pages the same way as the example

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.Color = xui.Color_White

    Root.LoadLayout("pageMain")
    FillViewPager
End Sub

Private Sub FillViewPager

    Dim lst As List
    lst.Initialize

    Dim page As Page
    page.Initialize("page")
    page.RootPanel.Color = Rnd(xui.Color_Black,xui.Color_White)
    page.RootPanel.As(B4XView).SetLayoutAnimated(0,0,0,Root.Width,Root.Height)
    page.RootPanel.LoadLayout("pvHome")
    lst.Add(page)
    spMain.AddPages(lst, "text")

I have added a breakpoint on
spMain.AddPages(lst, "text")

as soon as it entered the addpages (f8) i got the following message:

B4X:
Application_Start
Settings Loaded
Last Load 1635426173975
DEBUG API
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Application_Active
isFirst
AutoLogin true
*** page_login: B4XPage_Created [mainpage]
Class (b4i_b4xmainpage) instance released.
*** mainpage: B4XPage_Disappear [mainpage, page_login]
*** page_login: B4XPage_Appear [mainpage, page_login]
*** page_login: B4XPage_Resize [mainpage, page_login]
Login
Authorization
access_token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImViMTZlY2U3LTA2OTQtNDNjOC05MTI4LTg1MmE5Mjg2M2MxNiIsImlhdCI6MTYzNTQyNjUwMywiZXhwIjoxNjM1NTEyOTAzfQ.XS4rdMRCpJos9o_1d18E1i6x2rl4Ml_y5ocAGedf4a8
Class (b4i_httpjob) instance released.
UserAuthorization
user_access_token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjJkYWQyMmFmLWYzN2YtNDA3OS1hNWFkLTlkNmE4ZTQ2NDY1ZSIsImlhdCI6MTYzNTQyNjUwNCwiZXhwIjoxNjM1NTEyOTA0fQ.y5FqygAyFebCkEzWHn7zSdi0_zkvtqNoxGkzetsiWqI
*** page_main: B4XPage_Created [mainpage, page_login]
Class (b4i_bcpath) instance released.
Class (b4i_httpjob) instance released.
Class (b4i_bcpath) instance released.
*** page_login: B4XPage_Disappear [mainpage, page_login, page_main]
*** page_main: B4XPage_Appear [mainpage, page_login, page_main]
*** page_main: B4XPage_Resize [mainpage, page_login, page_main]
Error occurred on line: 97 (ASViewPagerNative)
[<b4i_asviewpager 0x281041a40> valueForUndefinedKey:]: this class is not key value coding-compliant for the key _lst_pages.
Stack Trace: (
  CoreFoundation       <redacted> + 252
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       <redacted> + 0
  Foundation           <redacted> + 248
  Foundation           <redacted> + 260
  SigaVaga             -[B4IShell getField] + 176
  SigaVaga             -[B4IShell raiseEventImpl:method:args::] + 2100
  SigaVaga             -[B4IShellBI raiseEvent:event:params:] + 1580
  SigaVaga             +[B4IDebug delegate:::] + 80
  SigaVaga             -[b4i_page_main _fillviewpager:] + 220
 SigaVaga             -[b4i_page_main _b4xpage_appear:] + 388
 CoreFoundation       <redacted> + 144
 CoreFoundation       <redacted> + 292
 SigaVaga             +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1300
 SigaVaga             -[B4IShell runMethod:] + 448
 SigaVaga             -[B4IShell raiseEventImpl:method:args::] + 2172
 SigaVaga             -[B4IShellBI raiseEvent:event:params:] + 1580
 SigaVaga             __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
 libdispatch.dylib    <redacted> + 24
 libdispatch.dylib    <redacted> + 16
 libdispatch.dylib    <redacted> + 1068
 CoreFoundation       <redacted> + 12
 CoreFoundation       <redacted> + 1924
 CoreFoundation       CFRunLoopRunSpecific + 436
 GraphicsServices     GSEventRunModal + 104
 UIKitCore            UIApplicationMain + 212
 SigaVaga             main + 120
 libdyld.dylib        <redacted> + 4
)
 

Alexander Stolte

Expert
Licensed User
Longtime User
this class is not key value coding-compliant for the key _lst_pages.
try to clean the project via the clean button in the ide.
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
try to clean the project via the clean button in the ide.
already did it, tested again twice with clean button and the same error happens as soon as enter the addPages sub

very strange in the draft library it did not happen
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
and never forget to wait for the Resize event, this can also cause strange behavior if this does not happen.
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.Color = xui.Color_White

    Root.LoadLayout("pageMain")
    #If B4i
    Wait For B4XPage_Resize (Width As Int, Height As Int)
    #End If
    FillViewPager
End Sub
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
and never forget to wait for the Resize event, this can also cause strange behavior if this does not happen.
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.Color = xui.Color_White

    Root.LoadLayout("pageMain")
    #If B4i
    Wait For B4XPage_Resize (Width As Int, Height As Int)
    #End If
    FillViewPager
End Sub

II have tried both, sleep and wait and did not worked

Cleaned the project many times

change the loadlayout to a simpler one with no maps, remove any initialization of the maps

on the test app there is no b4xpages, eventually there is a problem working with it?
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
but my test app is based on b4xpage
well, I am new to b4xpage and iOS.... almost sorry to be using it, it is so unconsistent...

EDIT: what does it means this error?

B4X:
Class (b4i_httpjob) instance released.
UserAuthorization
user_access_token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjJkYWQyMmFmLWYzN2YtNDA3OS1hNWFkLTlkNmE4ZTQ2NDY1ZSIsImlhdCI6MTYzNTQzMjE3NSwiZXhwIjoxNjM1NTE4NTc1fQ.tn0oACzlVraJgld62hS1XY1uxnvH-kQyxOW1zWXo-s8
*** page_main: B4XPage_Created [mainpage, page_login]
Class (b4i_bcpath) instance released.
Class (b4i_httpjob) instance released.
Class (b4i_bcpath) instance released.
*** page_login: B4XPage_Disappear [mainpage, page_login, page_main]
*** page_main: B4XPage_Appear [mainpage, page_login, page_main]
*** page_main: B4XPage_Resize [mainpage, page_login, page_main]
Class (b4i_bcpath) instance released.
Error occurred on line: 97 (ASViewPagerNative)
[<b4i_asviewpager 0x2837a5ce0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key _lst_pages.
Stack Trace: (
  CoreFoundation       <redacted> + 252
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       <redacted> + 0
  Foundation           <redacted> + 248
  Foundation           <redacted> + 260
  SigaVaga             -[B4IShell getField] + 176
  SigaVaga             -[B4IShell raiseEventImpl:method:args::] + 2100
  SigaVaga             -[B4IShellBI raiseEvent:event:params:] + 1580
  SigaVaga             -[B4IDebugResumableSub resume::] + 356
  SigaVaga             __21-[B4ICommon Sleep:::]_block_invoke + 48
 libdispatch.dylib    <redacted> + 24
 libdispatch.dylib    <redacted> + 16
 libdispatch.dylib    <redacted> + 1068
 CoreFoundation       <redacted> + 12
 CoreFoundation       <redacted> + 1924
 CoreFoundation       CFRunLoopRunSpecific + 436
 GraphicsServices     GSEventRunModal + 104
 UIKitCore            UIApplicationMain + 212
 SigaVaga             main + 120
 libdyld.dylib        <redacted> + 4
)
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
this class is not key value coding-compliant for the key _lst_pages.

can you try to delete your "Objects" folder and then recompile the project?
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User

can you try to delete your "Objects" folder and then recompile the project?
I have deleted the objects folder and the problem continues the same way

can you try to delete your "Objects" folder and then recompile the project?

B4X:
Public Sub AddPages(ListOfPanels As List)
    
    #If B4A
    AHPageContainer1.Initialize
    
    For i = 0 To ListOfPanels.Size -1   
        lst_Pages.Add("") 'Just a placeholder for future features
        AHPageContainer1.AddPage(ListOfPanels.Get(i).As(Panel),"")   
    Next

    AHViewPager1.PageContainer = AHPageContainer1
    #Else If B4I
    
    For i = 0 To ListOfPanels.Size -1
        lst_Pages.Add("") 'Just a placeholder for future features
    Next
    
    ChangePageNoAnimation(0)
    TabStrip1.SetPages(ListOfPanels)
    #End If
End Sub

B4X:
, _g_orientation=Horizontal, _g_carousel=0, _ismoving=0
, _g_isscrollenabled=1, _tag=, _dateutils=<b4i_dateutils: (null)>
, _main=<b4i_main: (null)>, _mycode=<b4i_mycode: (null)>, _yconsts=<b4i_yconsts: (null)>
, _b4xpages=<b4i_b4xpages: (null)>, _b4xcollections=<b4i_b4xcollections: (null)>, _httputils2service=<b4i_httputils2service: (null)>
, _xuiviewsutils=<b4i_xuiviewsutils: (null)>, _yglobalapiconsts=<b4i_yglobalapiconsts: (null)>], _viewpagerplaces=, _lstimage=<B4IList: (null)>
, _lstname=<B4IList: (null)>, _lstrank=<B4IList: (null)>, _lstduc=<B4IList: (null)>
, _lsttime=<B4IList: (null)>, _lstview=<B4IList: (null)>, _indexduc=0
, _btnpvhomelista=<B4XViewWrapper: (null)>, _btnpvhomelike=<B4XViewWrapper: (null)>, _wobblemenumain=
, _clvcaroptions=, _clvsettings=, _lblcardsettingssetting=<B4XViewWrapper: (null)>
, _lblcardsettingsicon=<B4XViewWrapper: (null)>, _lblpvsettingstitle=<B4XViewWrapper: <UILabel: 0x151e59530; frame = (90 15; 195 38); text = 'Configurações'; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x283b557c0>>>, _lblcaroptionstitle=<B4XViewWrapper: (null)>
, _lblcaroptionsdesc=<B4XViewWrapper: (null)>, _ivcaroptions=<B4XViewWrapper: (null)>, _btncardparkestacione=
, _lblparkplacename=<B4XViewWrapper: (null)>, _pnlpvhomeplaces=<B4IPanelWrapper: (null)>, _pnlpvhomemap=<B4XViewWrapper: (null)>
, _firsttime=0, _dateutils=<b4i_dateutils: (null)>, _main=<b4i_main: (null)>
, _mycode=<b4i_mycode: (null)>, _yconsts=<b4i_yconsts: (null)>, _b4xpages=<b4i_b4xpages: (null)>
, _b4xcollections=<b4i_b4xcollections: (null)>, _httputils2service=<b4i_httputils2service: (null)>, _xuiviewsutils=<b4i_xuiviewsutils: (null)>
, _yglobalapiconsts=< (message truncated)...
Stack Trace: (
  CoreFoundation       <redacted> + 252
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       <redacted> + 0
  SigaVaga             +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 336
  SigaVaga             -[B4IShell runMethod:] + 448
  SigaVaga             -[B4IShell raiseEventImpl:method:args::] + 1648
  SigaVaga             -[B4IShellBI raiseEvent:event:params:] + 1580
  SigaVaga             -[B4IDebugResumableSub resume::] + 356
  SigaVaga             __21-[B4ICommon Sleep:::]_block_invoke + 48
  libdispatch.dylib    <redacted> + 24
 libdispatch.dylib    <redacted> + 16
 libdispatch.dylib    <redacted> + 1068
 CoreFoundation       <redacted> + 12
 CoreFoundation       <redacted> + 1924
 CoreFoundation       CFRunLoopRunSpecific + 436
 GraphicsServices     GSEventRunModal + 104
 UIKitCore            UIApplicationMain + 212
 SigaVaga             main + 120
 libdyld.dylib        <redacted> + 4
)

it is a very weird error, since the sub is called correctly

B4X:
    Dim lst As List
    lst.Initialize
'
    Dim page As Page
    page.Initialize("page")
    page.RootPanel.Color = Rnd(xui.Color_Black,xui.Color_White)
    page.RootPanel.As(B4XView).SetLayoutAnimated(0,0,0,spMain.mBase.Width,spMain.mBase.Height)
    page.RootPanel.LoadLayout("pvSettings")
    lst.Add(page)
    Sleep(0)
    spMain.AddPages(lst)
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
I made this change and look what happens.... seems there is something about using list

B4X:
    Dim page As Page
    page.Initialize("page")
    page.RootPanel.Color = Rnd(xui.Color_Black,xui.Color_White)
    page.RootPanel.As(B4XView).SetLayoutAnimated(0,0,0,spMain.mBase.Width,spMain.mBase.Height)
    page.RootPanel.LoadLayout("pvSettings")
    lst.Add(page)
    Sleep(0)
    spMain.ListOfPanels = lst
    spMain.AddPages

B4X:
Login
Authorization
access_token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImViMTZlY2U3LTA2OTQtNDNjOC05MTI4LTg1MmE5Mjg2M2MxNiIsImlhdCI6MTYzNTUwOTAwNywiZXhwIjoxNjM1NTk1NDA3fQ.9-tSJxPZFn_ILMukiNTC-AvmGYLxHbODY87zSdGwAtI
Class (b4i_httpjob) instance released.
UserAuthorization
user_access_token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjJkYWQyMmFmLWYzN2YtNDA3OS1hNWFkLTlkNmE4ZTQ2NDY1ZSIsImlhdCI6MTYzNTUwOTAwOCwiZXhwIjoxNjM1NTk1NDA4fQ.Q0Ib4a0OARRRiKuQbeDazcNNEZNLkhCVefU47a0P44w
*** page_main: B4XPage_Created [mainpage, page_login]
Class (b4i_bcpath) instance released.
Class (b4i_httpjob) instance released.
Class (b4i_bcpath) instance released.
*** page_login: B4XPage_Disappear [mainpage, page_login, page_main]
*** page_main: B4XPage_Appear [mainpage, page_login, page_main]
*** page_main: B4XPage_Resize [mainpage, page_login, page_main]
Class (b4i_bcpath) instance released.
Error occurred on line: 100 (Page_Main)
[<b4i_asviewpager 0x283389f80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _listofpanels.
Stack Trace: (
  CoreFoundation       <redacted> + 252
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       <redacted> + 0
  Foundation           <redacted> + 264
  SigaVaga             -[B4IShell setField] + 212
  SigaVaga             -[B4IShell raiseEventImpl:method:args::] + 2116
  SigaVaga             -[B4IShellBI raiseEvent:event:params:] + 1580
  SigaVaga             -[B4IDebugResumableSub resume::] + 356
  SigaVaga             __21-[B4ICommon Sleep:::]_block_invoke + 48
  libdispatch.dylib    <redacted> + 24
 libdispatch.dylib    <redacted> + 16
 libdispatch.dylib    <redacted> + 1068
 CoreFoundation       <redacted> + 12
 CoreFoundation       <redacted> + 1924
 CoreFoundation       CFRunLoopRunSpecific + 436
 GraphicsServices     GSEventRunModal + 104
 UIKitCore            UIApplicationMain + 212
 SigaVaga             main + 120
 libdyld.dylib        <redacted> + 4
)
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
it is a very weird error, since the sub is called correctly
and it is an error that does not occur with me, so it is hard to try things out.

B4X:
this class is not key value coding-compliant for the key _lst_pages.
According to the error message and solutions at stackoverflow, the name "lst_Pages" must have a wrong class, but lst_Pages is of type List...

You can try to rename lst_Pages to ListPages
 
Upvote 0
Top