Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Back Button does not show,how to add back button to UINavigationItem

I add UINavigationBar via Library to view. I also add UINavigationItem to this NavigationBar.

In viewController.m,I added the following code but back button doesn't show.

self.navigationItem.title = @"List";
self.navigationItem.backBarButtonItem.title = @"Back";
like image 882
Phoenix Kyaw Avatar asked Oct 06 '11 06:10

Phoenix Kyaw


People also ask

How do I show the back button in Swift?

Back-button text is taken from parent view-controller's navigation item title. So whatever you set on previous view-controller's navigation item title, will be shown on current view controller's back button text. You can just put "" as navigation item title in parent view-controller's viewWillAppear method.

Where is the navigation bar button?

The Navigation bar is the menu that appears on the bottom of your screen - it's the foundation of navigating your device. However, it isn't set in stone; you can customize the layout and button order, or even make it disappear entirely and use gestures to navigate your device instead.

How can hide back button in IOS?

Way 1: Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.


1 Answers

Try this:

self.navigationItem.leftItemsSupplementBackButton = YES;

or

navigationItem.leftItemsSupplementBackButton = true

If you customize your navigation controller with UIBarButtonItems the framework removes the back button by default, since it assumes you are customizing the Navigation bar. Use that line to add the back button in again.

like image 76
smileBot Avatar answered Jan 28 '23 19:01

smileBot