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
a small example project would be helpful.
a b4XPage example you find here:

but i dont think that b4xpage is the native ios Page object.
i am not sure you can use b4xpages in this scenario.
But it works in my test project
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
The problem is something else, look this:
I made several changes to understand the param passing and it is a problem for anything

So, looks like there is something else happening.

B4X:
    Log(spMain.Whatever("teste"))
    spMain.AddPage("pvSettings")
    spMain.AddPages

on this line Log(spMain.Whatever("teste"))

B4X:
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: 99 (ASViewPagerNative)
[<b4i_asviewpager 0x281e25f80> valueForUndefinedKey:]: 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> + 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:] + 384
 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
)

1635511882573.png



B4X:
public Sub Whatever(test As String) As String
    Return test
End Sub
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
can you put a Sleep(0) under mBase.LoadLayout("...") in the class?

found the main problem!

on the layout loaded for the spMain was a ASViewPager instead of ASViewPagerNative

in the code was defined:
Private spMain As ASViewPagerNative

so it compiled but during execution it could not find that sub because it was not really there...

corrected the mistake, returned to the original ASViewPagerNative b4xlib from your thread and it worked

however there is a remaining problem :

B4X:
Unexpected event (missing RaisesSynchronousEvents): tabstrip1_pageselected:
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
found the main problem!
So it wasn't up to me?

Unexpected event (missing RaisesSynchronousEvents): tabstrip1_pageselected:
You can ignore that, it happens because I set the index to 0 before adding a page so the viewpager doesn't start on the last page. Maybe I can still optimize this.
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
So it wasn't up to me?
Nom it was not your fault.... it was mine, testing on both platforms in a project already big and trying to learn many quickrs of B4i lead me to this mistake..... I saw that in design the properties were not large enough in my screen and i thought was the right class.

Interesting is that it accepted on the source code the different declaration... so in part I think b4i should be more carefull

Anyways, I see you were very helpful and with true spirit of comunity. I am extremelly happy with your help.

Next week I will buy one or two beers for you!
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Anyways, I see you were very helpful and with true spirit of comunity. I am extremelly happy with your help.
When I read that you are already behind schedule, I wanted to help as soon as possible.

Next week I will buy one or two beers for you!
Thanks!
 
Upvote 0
Top