iOS Question BarButton text change

Discussion in 'iOS Questions' started by klaus, Nov 2, 2014.

  1. klaus

    klaus Expert Licensed User

    Does there exist an easy way to change the text of a BarButton.
    Example: Filter > UnFilter > Filter
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can use this sub to replace the text of a toolbar button based on its tag:
    Code:
    Sub ReplaceBarButtonText(Tag As String, NewText As String)
       
    Dim buttons As List = Page1.ToolbarButtons
       
    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
       Page1.ToolbarButtons = buttons
    End Sub
     
    klaus likes this.
  3. klaus

    klaus Expert Licensed User

    Thank you Erel,
    I was thinking about something like this but hadn't tried it.
     
  4. MikeH

    MikeH Well-Known Member Licensed User

    Is there a simpler way of doing this? I only have one toolbar button and I want to change its text or visibility.

    Thanks :)
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Two simple options:
    1. Just add this sub and call ReplaceBarButtonText("ButtonTag", "New Text").
    2. Create a new BarButton and set it:
    Code:
    Dim b1 As BarButton
    b1.InitializeText(
    "New Text""Tag")
    Page1.TopRightButtons = 
    Array(b1)
     
    MikeH likes this.
  6. MikeH

    MikeH Well-Known Member Licensed User

    Great, the 2nd option worked a treat. Thanks Erel.
     
  7. dieterp

    dieterp Active Member Licensed User

    Is it possible to do the following:

    1) Open a page, hide the back button and set a TopLeftButton to some new value
    2) Perform some operation (Like display a Tableview) and then click the TopLeftButton to return to the same page I was on (Remove the Tableview)
    3) Remove the TopLeftButton and then display the back button with the original 'back' link that the page opened with
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
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