iOS Code Snippet Change BackButton Title

Discussion in 'iOS Code Snippets' started by Emme Developer, Jul 27, 2017.

  1. Emme Developer

    Emme Developer Well-Known Member Licensed User

    I search it on forum, but i didn't find nothing.
    This code will change back button Title, instead using name of previus page

    Dim na As NativeObject = Me

    #If OBJC
    - (void)ChangeTitle: (UINavigationController*) nav : (NSString*) Title{
    UIBarButtonItem *barButton = [[UIBarButtonItem alloc] init];
    barButton.title = Title;
    nav.navigationBar.topItem.backBarButtonItem = barButton;
    #End If
    Nav is the navigation controller; You can change "Back" with what you want
    Last edited: Jul 27, 2017
  2. Erel

    Erel Administrator Staff Member Licensed User

    The back button text is the previous page title.

    If you want to set a BarButton then you can also do it with this code:
    Dim bb As BarButton

    Dim no As NativeObject = NavControl
    "navigationBar").GetField("topItem").SetField("backBarButtonItem", bb)
    This is better as it makes it simpler to customize the button.
    Emme Developer likes this.