iOS Code Snippet Change BackButton Title

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

B4X:
Dim na As NativeObject = Me
na.RunMethod("ChangeTitle::",Array(nav,"Back"))

#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:

Erel

B4X founder
Staff member
Licensed User
Longtime 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:
B4X:
Dim bb As BarButton
bb.InitializeText("MyBack", "MyBack")

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