iOS Question change top left buttons text

le_toubib

Active Member
Licensed User
Longtime User
hi

i'm using this code to change text:
B4X:
Sub ReplaceBarButtonText(Tag As String, NewText As String)
   Dim buttons As List = page0.TopRightButtons
   For i = 0 To buttons.Size - 1
     Dim bb As BarButton = buttons.Get(i)
     If bb.Tag = Tag Then
       Dim newButton As BarButton
       newButton.InitializeText(NewText, Tag)
       buttons.Set(i, newButton)
       Exit
     End If
   Next

Page0.TopLeftButtons = buttons

End Sub



but i get this error , on the line ( buttons.Set(i, newButton) ) :

Application_Start
Error occurred on line: 1025 (main)
-[__NSArrayI setObject:atIndexedSubscript:]: unrecognized selector sent to instance 0x15557a60
Stack Trace: (
CoreFoundation <redacted> + 154
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 202
CoreFoundation <redacted> + 706
CoreFoundation _CF_forwarding_prep_0 + 24
ADHD -[B4IList Set::] + 192
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 282
ADHD +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1928
ADHD -[B4IShell runVoidMethod] + 210
ADHD -[B4IShell raiseEventImpl:method:args::] + 2002
ADHD -[B4IShellBI raiseEvent:event:params:] + 1316
ADHD __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
libdispatch.dylib <redacted> + 10
libdispatch.dylib <redacted> + 22
libdispatch.dylib <redacted> + 278
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 1300
CoreFoundation CFRunLoopRunSpecific + 522
CoreFoundation CFRunLoopRunInMode + 106
GraphicsServices GSEventRunModal + 138
UIKit UIApplicationMain + 1136
ADHD main + 116
libdyld.dylib <redacted> + 2
)


what am i doing wrong?
 

le_toubib

Active Member
Licensed User
Longtime User
ok, thanks erel, that was my mistake , my aim is to change the toprightbuttons (the ons i set in the designer)

but i changed the code into :
B4X:
Sub ReplaceBarButtonText(Tag As String, NewText As String)
   Dim buttons As List = Page0.TopRightButtons
        Dim newButton As BarButton
       newButton.InitializeText(NewText, "btn_Scale")
       buttons.Set(2, newButton)
       Page0.TopRightButtons = buttons
End Sub

but i still get the same error.
what am i doing wrong
 
Upvote 0
Top