iOS Question change top left buttons text

Discussion in 'iOS Questions' started by le_toubib, Jun 9, 2015.

  1. le_toubib

    le_toubib Active Member Licensed User

    hi

    i'm using this code to change text:
    Code:
    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) ) :


    what am i doing wrong?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Change the first line to get the TopLeftButtons instead of the TopRightButtons.
     
  3. le_toubib

    le_toubib Active Member Licensed 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 :
    Code:
    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
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Use the debugger and check the value of buttons. If you are unable to solve it please create a small project and upload it.
     
    le_toubib likes this.
  5. RVP

    RVP Active Member Licensed User

    How did you solve this? I am having the same issue.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice