iOS Question SOLVED - iOS ASTabMenu question: TabClick event not firing

cjpryor

Active Member
Licensed User
So, I am looking for advice as to what I might need to do to make my B4X design work in iOS.

I used B4XPages (and XUI) to develop a desktop application in B4J that uses the ASTabMenu control for navigation. It works fine in Windows, Mac, and Linux. However, when run as an iOS application the ASTabMenu TabClick event is not fired.

An iOS ASTabMenu example downloaded from the forum works, but it does not support my desired functionality. The only difference I can find is the sample iOS application forces the end user to return to the main page to switch to a different page.

My design has a Main Page that simply lists available items with no need for the ASTabMenu. Once an item is selected, data for that item is divided across multiple "subsequent" pages and I want the ASTabMenu to be visible at all times on all "subsequent" pages so a user can easily switch between pages without having to return to the main page.

Here are some screen shots (from my B4J application) to illustrate what I am talking about. This a just a couple of the "subsequent" pages for illustration. The "home" button returns the user back to the Main Page. The iOS application looks the same but the TabClick event does not fire. It is almost as if the ASTabMenu is disabled so I added ASTabMenu1.ViewEnable(True) to each B4XPage_Appear event but it made no difference.

Main Page:

MainPage.jpg


Subsequent Page 1:

Identification.jpg


Subsequent Page 2:

Description.jpg


Thanks in advance!

Clay
 
Last edited:

cjpryor

Active Member
Licensed User
I'm going to see if I can replicate my preferred design in the sample project I downloaded. If it works then I might have a better idea of what might be wrong in mine. If it behaves the same it will give anybody who wants to help something to work with. :)
 
Last edited:
Upvote 0

cjpryor

Active Member
Licensed User
hmm, I was able to successfully deploy my design in the sample app. Now to figure out why mine works in B4J but not B4i. If anybody knows of any common pitfalls I would appreciate the feedback. Thanks!
 
Upvote 0

cjpryor

Active Member
Licensed User
The invisible panel idea would explain the lack of response. Unfortunately, it does not seem to be hidden and I do not add any panels programatically.

pageLayout.jpg
 
Upvote 0

cjpryor

Active Member
Licensed User
and in what do you load this layout? Root panel? Root page?
Let's see if I can get the code to display right:

B4X:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
  
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("ItemPageCLV_Layout")
 
Upvote 0

cjpryor

Active Member
Licensed User
FYI - this is what it looks like on my iPhone. I can click anything and everything but the tabs.

iOS_Tab.png
 
Last edited:
Upvote 0

cjpryor

Active Member
Licensed User
Does it work in portrait mode before you rotate the display?
Do you have the latest version?
It does not work in any orientation (portrait or landscape). I downloaded the latest version (v. 7.8.0) of B4i before starting my iOS development a few days ago.
 
Upvote 0

cjpryor

Active Member
Licensed User
ahhhh, add this after you load the layout:
B4X:
#If B4I
Wait For B4XPage_Resize (Width As Int, Height As Int)
#End If
Thank you! I tried it and am getting an error somewhere else in the program that I have yet to find but running out of time to troubleshoot tonight. Will revisit in the morning.

This is the stack trace:

B4X:
Application_Start
reportsDir = [/var/mobile/Containers/Data/Application/E5F78461-C6CE-45C8-B9E4-8C646103C018/Documents/Reports]
commonProcesses.exportsDir = [/var/mobile/Containers/Data/Application/E5F78461-C6CE-45C8-B9E4-8C646103C018/Documents/Exports]
picturesDir = [/var/mobile/Containers/Data/Application/E5F78461-C6CE-45C8-B9E4-8C646103C018/Documents/Pictures]
ExecuteMemoryTable: SELECT TEXT5 FROM SYSTEM 
Current Database Version = [2.0]
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Application_Active
Application_Foreground
Application_Active
XPC connection interrupted
ExecuteMemoryTable: SELECT
    COLLECTIONNAME 
    FROM COLLECTIONTEMPLATES 
    ORDER BY COLLECTIONNAME COLLATE NOCASE ASC
ExecuteMemoryTable: SELECT
    COLLECTIONID
    FROM COLLECTIONTEMPLATES 
    WHERE COLLECTIONNAME = 'Firearms' 
Class (b4i_itemlistitem) instance released.
Error occurred on line: 987 (ASTabMenu)
*** -[__NSArray0 objectAtIndex:]: index 1 beyond bounds for empty NSArray
Stack Trace: (
  CoreFoundation       EA9C1DF2-94C7-379B-BF8D-970335B1552F + 597168
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       EA9C1DF2-94C7-379B-BF8D-970335B1552F + 1122832
  nmCollectorCP        -[B4IPanelWrapper GetView:] + 92
  nmCollectorCP        -[B4XViewWrapper GetView:] + 104
  nmCollectorCP        -[b4i_astabmenu _settab::::] + 604
  nmCollectorCP        -[ResumableSub_itemidscrollpage_B4XPage_Appear resume::] + 380
  nmCollectorCP        -[b4i_itemidscrollpage _b4xpage_appear:] + 308
  CoreFoundation       EA9C1DF2-94C7-379B-BF8D-970335B1552F + 133328
  CoreFoundation       EA9C1DF2-94C7-379B-BF8D-970335B1552F + 247208
 nmCollectorCP        +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1300
 nmCollectorCP        -[B4IShell runMethod:] + 416
 nmCollectorCP        -[B4IShell raiseEventImpl:method:args::] + 1984
 nmCollectorCP        -[B4IShellBI raiseEvent:event:params:] + 1580
 nmCollectorCP        __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
 libdispatch.dylib    56AA6E93-8D8E-32FE-AC73-D3E79B1BA2F5 + 405908
 libdispatch.dylib    56AA6E93-8D8E-32FE-AC73-D3E79B1BA2F5 + 410008
 libdispatch.dylib    56AA6E93-8D8E-32FE-AC73-D3E79B1BA2F5 + 67024
 CoreFoundation       EA9C1DF2-94C7-379B-BF8D-970335B1552F + 317416
 CoreFoundation       EA9C1DF2-94C7-379B-BF8D-970335B1552F + 45288
 CoreFoundation       CFRunLoopRunSpecific + 572
 GraphicsServices     GSEventRunModal + 160
 UIKitCore            FB5C2D36-6A05-3355-B898-D8D3C163D02E + 5161052
 UIKitCore            UIApplicationMain + 2028
 nmCollectorCP        main + 104
 dyld                 start + 444
)
 
Upvote 0

cjpryor

Active Member
Licensed User
maybe something in the B4XPage_Appear event?
Yes, it crashes on the SetTab in B4XPage_Appear:

B4X:
Public Sub B4XPage_Appear

    ASTabMenu1.SetTab(MainPage.processes.IDTAB,False,False)

Also, some subsequent statements appear to be skipped after the Wait For ... I think I need to add a Complete clause with follow-up to the Wait For statement but I get a syntax error when I try to add a Complete clause - I need to spend more time researching this.

And, the debugger is not showing any values for ASTabMenu1 at this point. If I remove your suggested Wait For statement the application crashes if I set a breakpoint at the SetTab.

I wonder if I have some sort of initialization issue ... still looking.

Thanks again for your suggestions.
 
Upvote 0

cjpryor

Active Member
Licensed User
So I moved the "Wait For ..." to the end of the B4XPage_Created event, which allowed my other statements to be executed, and the error went away but the TabClick event is still not fired. I am going to revisit everything since the sample works but the same design does not work in my application.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
So I moved the "Wait For ..." to the end of the B4XPage_Created event
makes no sense, because if the resize event is faster then the created event, then you are waiting forever.

and the issue with the no click event comes from the missing wait for at the beginning.

Public Sub B4XPage_Appear ASTabMenu1.SetTab(MainPage.processes.IDTAB,False,False)
B4X:
If ASTabMenu1.TabSize > 0 Then
    ASTabMenu1.SetTab(MainPage.processes.IDTAB,False,False)
End If
 
Upvote 0

cjpryor

Active Member
Licensed User
makes no sense, because if the resize event is faster then the created event, then you are waiting forever.

and the issue with the no click event comes from the missing wait for at the beginning.


B4X:
If ASTabMenu1.TabSize > 0 Then
    ASTabMenu1.SetTab(MainPage.processes.IDTAB,False,False)
End If

First, let me just thank you again for helping me!

Here is my complete B4XPage_Created event. If I add a beakpoint on the line following the Wait For ..., it is not reached and I get the error posted earlier. If I comment out the Wait For ... the breakpoint is reached and I get no error. Moving the Wait For ... to the end of the event allows all of the other lines of code to be reached and I get no errors.

On a related note, I tried replacing the call to MainPage.addTabs(ASTabMenu1) with the actual addTab statements but that, as I expected, did not make a difference.

B4X:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
        
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("ItemPageCLV_Layout")
    
    #If B4i
    Wait For B4XPage_Resize (Width As Int, Height As Int)
    #End If
    
    'Pages are never destroyed so we need to reuse them
    
    captionListText.initialize
    fieldValuesListText.initialize
    captionListDecimal.initialize
    fieldValuesListDecimal.initialize
    captionListDate.initialize
    fieldValuesListDate.initialize
    captionListNote.initialize
    fieldValuesListNote.initialize

    MainPage.addTabs(ASTabMenu1)

    firstVisible = 0
    lastSelectedRow = 0
    
End Sub
 
Upvote 0

cjpryor

Active Member
Licensed User
Thanks for the advice. I'm not sure I did what you suggested but there were no errors. However, the tabclicks are still not triggered. However, I think I am still on v1.22 so I need to figure out how to upgrade it.

Anyway, this is what I did:

B4X:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
      
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("ItemPageCLV_Layout")
  
    #If B4i
'    Wait For B4XPage_Resize (Width As Int, Height As Int)
'     Just guessing on what to use for width and height for testing
    B4XPage_Resize (100, 100)
    #End If
  
    'Pages are never destroyed so we need to reuse them
  
    captionListText.initialize
    fieldValuesListText.initialize
    captionListDecimal.initialize
    fieldValuesListDecimal.initialize
    captionListDate.initialize
    fieldValuesListDate.initialize
    captionListNote.initialize
    fieldValuesListNote.initialize

    MainPage.addTabs(ASTabMenu1)

    firstVisible = 0
    lastSelectedRow = 0
  
End Sub

B4X:
Sub B4XPage_Resize (Width As Int, Height As Int)
  
    '???? what do do here ????
  
End Sub

Here is my version info:

ASTabMenu.png


On a related note, I am slowly building on the ASTabMenu example to more closely match what I am doing. So far it continues to work but the pages are very simple.
 
Upvote 0
Top