iOS Question iTabStrip

Cristian Achim

Member
Licensed User
Longtime User
Hello,
I have a problem with iTabStrip library. I want to automatically remove second tab/page when first tab/page is selected.
I have following code that works fine if I press on the first tab of the TabStrip.

B4X:
Sub TabStrip_PageSelected (Position As Int)
    If Position = 0 Then
        Page1.RootPanel.RemoveAllViews
        TabPages.RemoveAt(1)
        TabStrip.SetPages(TabPages)
    End If
End Sub

The problem appear when I try to select first tab from code with one of those commands:
TabStrip.CurrentPage = 0 OR TabStrip_PageSelected(0)

The app crash with following error:

B4X:
Error occurred on line: 1307 (App_Order)
*** -[__NSArrayM removeObjectsInRange:]: range {1, 1} extends beyond bounds [0 .. 0]
Stack Trace: (
  CoreFoundation       00E76A98-210C-3CB5-930B-F236807FF24C + 540460
  libobjc.A.dylib      objc_exception_throw + 60
  CoreFoundation       00E76A98-210C-3CB5-930B-F236807FF24C + 82696
  RTOrder              -[B4IList RemoveAt:] + 60
  CoreFoundation       00E76A98-210C-3CB5-930B-F236807FF24C + 133140
  CoreFoundation       00E76A98-210C-3CB5-930B-F236807FF24C + 129120
  RTOrder              +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1296
  RTOrder              -[B4IShell runVoidMethod] + 208
  RTOrder              -[B4IShell raiseEventImpl:method:args::] + 1608
  RTOrder              __40-[B4IShell raiseEventImpl:method:args::]_block_invoke + 36
 libdispatch.dylib    81D355DF-266A-3010-BAB8-113B76A206C1 + 8508
 libdispatch.dylib    81D355DF-266A-3010-BAB8-113B76A206C1 + 15828
 libdispatch.dylib    81D355DF-266A-3010-BAB8-113B76A206C1 + 75172
 libdispatch.dylib    _dispatch_main_queue_callback_4CF + 44
 CoreFoundation       00E76A98-210C-3CB5-930B-F236807FF24C + 354064
 CoreFoundation       00E76A98-210C-3CB5-930B-F236807FF24C + 342292
 CoreFoundation       CFRunLoopRunSpecific + 608
 GraphicsServices     GSEventRunModal + 164
 UIKitCore            1741FA37-4E53-371E-8DAE-D611AAB0043D + 4237580
 UIKitCore            UIApplicationMain + 340
 RTOrder              main + 100
 dyld                 71846EAC-EE65-3697-BF7D-790B6A07DCDB + 249420
)

Thank you!
 

Cristian Achim

Member
Licensed User
Longtime User
Hello!
I solved with this:
B4X:
Sub ChangePageNoAnimation (Index as Int)
Dim no As NativeObject = TabStrip1
no.RunMethod("moveToViewControllerAtIndex:animated:", Array(Index, False))
End Sub
Thank you @Erel!
 
Upvote 1
Top